The main purpose of this problem is to identify the phone calls among two people. First, we have to consider the roll number as nodes, and the friendship among any two members as edges. If we start a Breadth First Search from node 0, at the end we will find a BFS tree. While exploring the neighbour nodes, we have to explore them in ascending order, to get an unique BFS tree. Then we will just store the edge of the BFS tree and for any query, if there is an edge between a and b in the BFS tree, we will print “Yes” and “No” otherwise.