I attempted BUGLIFE, used the concept of bipartite graph. But can't figure out why I was getting a WA. My code is given as below
http://code.geeksforgeeks.org/uLsQi4