approach: first I check for the common value in 1st and 2nd pair, and put that in X(array).

After that traverse through pairs, if at any point value of pair is not equal to x and y is not yet been assigned value then y is assumed as y1(first value of current pair), then again check if a pair match x or current y, else change the value of y to y2. Check if an element of current pair is equal to y2 if not then set flag to false.

Then finally check if there exist a True in ans, print “YES” else “NO”.

What am I missing?