Magnetism in a graphene-4f-3d hybrid system