The first line contains an integer T (1≤T≤10), the number of test cases.
Each test case starts with a line holding an integer n (1≤n≤50000), the number of cards in Mike's hand. Each of the next n lines describes one card with two integers pi and qi (1≤pi,qi≤2n), the pictures on its two sides. Pictures are written as integers.