ESR and optical measurements of LiNbO3 and LiTaO3 single crystals doped with ions of the first transition series