Editorial for TOURIST

Hi there, in the very first test-case the input is like :

2 2
1 2
2 1

your code’s output is:

YES
1 2

I guess you’re not printing the required edges.

Hi there, you’re not printing the edges in the required order.
Your algorithm seems to be correct. Consider the input:

2 2
2 1
1 2

Your code prints

YES
1 2
2 1

Thus the order is not as in the input.