{"trustable":false,"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":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don\u0027t know that Computer College had ever been split into Computer College and Software College in 2002. \n \u003cbr\u003eThe splitting is absolutely a big event in HDU! At the same time, it is a trouble thing too. All facilities must go halves. First, all facilities are assessed, and two facilities are thought to be same if they have the same value. It is assumed that there is N (0\u0026lt;N\u0026lt;1000) kinds of facilities (different value, different kinds). \n \u003cbr\u003e \n中文总结:分割,使的两部分的价值最接近\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"Input contains multiple test cases. Each test case starts with a number N (0 \u0026lt; N \u0026lt;\u003d 50 -- the total number of different facilities). The next N lines contain an integer V (0\u0026lt;V\u0026lt;\u003d50 --value of facility) and an integer M (0\u0026lt;M\u0026lt;\u003d100 --corresponding number of the facilities) each. You can assume that all V are different. \n\u003cbr\u003eA test case starting with a negative integer terminates input and this test case is not to be processed. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each case, print one line containing two integers A and B which denote the value of Computer College and Software College will get respectively. A and B should be as equal as possible. At the same time, you should guarantee that A is not less than B. \n\u003cbr\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e2\n10 1\n20 1\n3\n10 1 \n20 2\n30 1\n-1\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e20 10\n40 40\u003c/pre\u003e"}}]}