{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e$N$ people numbered from 1 to $N$ are waiting in a bank for service. They all stand in a queue, but the queue never moves. It is lunch time now, so they decide to go out and have lunch first. When they get back, they don’t remember the exact order of the queue. Fortunately, there are some clues that may help.\u003cbr\u003eEvery person has a unique height, and we denote the height of the $i$-th person as $h_i$. The $i$-th person remembers that there were $k_i$ people who stand before him and are taller than him. Ideally, this is enough to determine the original order of the queue uniquely. However, as they were waiting for too long, some of them get dizzy and counted $k_i$ in a wrong direction. $k_i$ could be either the number of taller people before or after the $i$-th person.\u003cbr\u003eCan you help them to determine the original order of the queue?\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of input contains a number $T$ indicating the number of test cases ($T≤1000$).\u003cbr\u003eEach test case starts with a line containing an integer $N$ indicating the number of people in the queue ($1≤N≤100000$). Each of the next $N$ lines consists of two integers $h_i$ and $k_i$ as described above ($1≤h_i≤10^9,0≤k_i≤N-1$). Note that the order of the given $h_i$ and $k_i$ is randomly shuffled.\u003cbr\u003eThe sum of $N$ over all test cases will not exceed $10^6$\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output a single line consisting of “Case #X: S”. $X$ is the test case number starting from 1. $S$ is people’s heights in the restored queue, separated by spaces. The solution may not be unique, so you only need to output the smallest one in lexicographical order. If it is impossible to restore the queue, you should output “impossible” instead."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n3\r\n10 1\r\n20 1\r\n30 0\r\n3\r\n10 0\r\n20 1\r\n30 0\r\n3\r\n10 0\r\n20 0\r\n30 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 20 10 30\r\nCase #2: 10 20 30\r\nCase #3: impossible\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}