FRIENDS of FRIENDS

http://www.spoj.com/problems/FACEFRND/