{"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 《Shui Hu Zhuan》,also 《Water Margin》was written by Shi Nai\u0027an -- an writer of Yuan and Ming dynasty. 《Shui Hu Zhuan》is one of the Four Great Classical Novels of Chinese literature. It tells a story about 108 outlaws. They came from different backgrounds (including scholars, fishermen, imperial drill instructors etc.), and all of them eventually came to occupy Mout Liang(or Liangshan Marsh) and elected Song Jiang as their leader.\u003cbr\u003e\u003cbr\u003e In order to encourage his military officers, Song Jiang always made a rank list after every battle. In the rank list, all 108 outlaws were ranked by the number of enemies he/she killed in the battle. The more enemies one killed, one\u0027s rank is higher. If two outlaws killed the same number of enemies, the one whose name is smaller in alphabet order had higher rank. Now please help Song Jiang to make the rank list and answer some queries based on the rank list.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":" There are no more than 20 test cases.\u003cbr\u003e\u003cbr\u003e For each test case:\u003cbr\u003e\u003cbr\u003e The first line is an integer N (0\u0026lt;N\u0026lt;200), indicating that there are N outlaws.\u003cbr\u003e\u003cbr\u003e Then N lines follow. Each line contains a string S and an integer K(0\u0026lt;K\u0026lt;300), meaning an outlaw\u0027s name and the number of enemies he/she had killed. A name consists only letters, and its length is between 1 and 50(inclusive). Every name is unique. \u003cbr\u003e\u003cbr\u003e The next line is an integer M (0\u0026lt;M\u0026lt;200) ,indicating that there are M queries.\u003cbr\u003e\u003cbr\u003e Then M queries follow. Each query is a line containing an outlaw\u0027s name. \u003cbr\u003eThe input ends with n \u003d 0"}},{"title":"Output","value":{"format":"HTML","content":" For each test case, print the rank list first. For this part in the output ,each line contains an outlaw\u0027s name and the number of enemies he killed. \u003cbr\u003e\u003cbr\u003e Then, for each name in the query of the input, print the outlaw\u0027s rank. Each outlaw had a major rank and a minor rank. One\u0027s major rank is one plus the number of outlaws who killed more enemies than him/her did.One\u0027s minor rank is one plus the number of outlaws who killed the same number of enemies as he/she did but whose name is smaller in alphabet order than his/hers. For each query, if the minor rank is 1, then print the major rank only. Or else Print the major rank, blank , and then the minor rank. It\u0027s guaranteed that each query has an answer for it. "}},{"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\u003e5\r\nWuSong 12\r\nLuZhishen 12\r\nSongJiang 13\r\nLuJunyi 1\r\nHuaRong 15\r\n5\r\nWuSong\r\nLuJunyi\r\nLuZhishen\r\nHuaRong\r\nSongJiang\r\n0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eHuaRong 15\r\nSongJiang 13\r\nLuZhishen 12\r\nWuSong 12\r\nLuJunyi 1\r\n3 2\r\n5\r\n3\r\n1\r\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}