You are given a connected simple undirected graph with vertices and edges. The vertices are numbered from to .
Find a closed walk that traverses every edge exactly twice. Two consecutive traversals must not use the same edge. The last and first traversals must also use different edges.
Definition of a Walk
A walk in a graph is a sequence of vertices such that an edge exists between and for every (). A walk may visit the same vertex or traverse the same edge multiple times.
There is no restriction on the direction in which an edge is traversed. If no such closed walk exists, report that it is impossible.
The input is given in the following format:
For each test case, if no valid closed walk exists, print NO on one line.
Otherwise, print YES on the first line. On the second line, print the visited vertices , separated by spaces.
One answer for the first test case is . The second test case has no valid closed walk.
A walk is called a closed walk if its starting and ending vertices are the same, that is, .
is the number of test cases. Each test case is given in the following format:
Edge joins vertices and ().
It must hold that . For every (), an edge must join and , and traversing these edges in order must satisfy all the conditions in the statement. You may choose any starting vertex. If there are multiple solutions, print any of them.
No additional constraints.