There are $N$ stacks, numbered from $1$ to $N$. Initially, the $i$-th stack only contains a number $i$. Now there are $M$ move operations, and the $i$-th operation is to move all the numbers in stack $a_i$ to stack $b_i$. Specifically speaking, we pop all the numbers in stack $a_i$ one by one, and push them to stack $b_i$ in the order of popping (the first to be popped is the first to be pushed).
After all the $M$ operations, you should output the numbers in the stacks.