{"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\u003ci\u003eTI10 and ICPC World Finals 2020, which will be held earlier? Take a bet!\u003c/i\u003e\u003cbr\u003e\u003cbr\u003eThe International(TI) is the biggest and most prestigious event of Dota2 and is commonly held annually in August. The Dota2 teams should try to earn points to be eligible to compete in TI. There are two ways of earning points, first is by competing in the regional contests, second is by competing in the tournaments, where all teams are gathered to compete together and earn points according to their rank in the tournament. A team\u0027s final score is the sum of scores from both the regional contests and tournaments.\u003cbr\u003e\u003cbr\u003eNow that the regional contests have finished, there are $n$ teams taking part, and the $i$th team has earned $a_i$ points from the regional contests. Also, the team that gets the $i$th rank in the tournament can gain $b_i$ points.\u003cbr\u003e\u003cbr\u003ecyz is a huge fan of Dota2. So before the tournament starts, he will predict the final rank of all teams. cyz wants to know, for each team, what\u0027s its best possible rank and its worst possible rank after the tournament finishes.\u003cbr\u003e\u003cbr\u003eIf a team has a final score equal to $x$, its rank is defined as one plus the number of teams with a strict higher score than it. For example, if the final score of four teams are $700,500,500,300$ respectively, then their final ranks are $1,2,2,4$, respectively.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a number $T(1\\leq T\\leq 20)$, denoting the number of test cases.\u003cbr\u003e\u003cbr\u003eThe first line of each test case contains one number $n(1\\leq n\\leq 5000)$, denoting the number of different teams that participate in the regional contests and tournaments.\u003cbr\u003e\u003cbr\u003eThe next line contains $n$ integers $a_1,a_2,\\dots,a_n(0\\leq a_i\\leq 10^9)$, denoting the points of each team before the tournament starts.\u003cbr\u003e\u003cbr\u003eThen follows one line containing $n$ integers $b_1,b_2,\\dots,b_n(0\\leq b_n\\leq b_{n-1}\\leq ...\\leq b_1 \\leq 10^9)$, where $b_i$ denotes the number of points a team would get if ranking $i$th in the tournament.\u003cbr\u003e\u003cbr\u003eIt is guaranteed that there are at most 8 cases with $n\u0026gt;100$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output $n$ lines, where the $i$th line contains two integers $best_i,worst_i(1\\leq best_i\\leq worst_i\\leq n)$, denoting the best possible and worst possible rank a team would get after the tournament finishes."}},{"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\u003e2\r\n3\r\n5 10 8\r\n5 2 1\r\n2\r\n5 6\r\n4 4\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2 3\r\n1 2\r\n1 3\r\n2 2\r\n1 1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}