3d and 4f Magnetism in Nd2Fe14-xCoxB and Y2Fe14-xCoxB Compounds