UVA Forwarding Emails

While Solving Graph problem i Got stuck at this problem and I am unable to come up with an Efficient solution. Although, Brute force can be done But I know it will get T.L.E. Can any body explain his approach properly, I will be very happy to be guided by this wonderful community.Thanks in Advance.