{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e\r\nh1,h2,h3,h4,h5,h6{margin-bottom:0;}div.textBG p{margin: 0 0 0.0001pt;}\u003c/style\u003e\r\n\u003cp\u003e\r\n\tMasterMind is a game for two players. One of them, \u003ci\u003eDesigner\u003c/i\u003e, selects a secret code. The other, \u003ci\u003eBreaker\u003c/i\u003e, tries to break it. A code is no more than a row of colored dots. At the beginning of a game, the players agree upon the length \u003ci\u003eN\u003c/i\u003e that a code must have and upon the colors that may occur in a code.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tIn order to break the code, Breaker makes a number of guesses, each guess itself being a code. After each guess Designer gives a hint, stating to what extent the guess matches his secret code.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tIn this problem you will be given a secret code \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline35\" height\u003d\"17\" src\u003d\"http://uva.onlinejudge.org/external/3/340img1.gif\" width\u003d\"57\" /\u003e and a guess \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline37\" height\u003d\"17\" src\u003d\"http://uva.onlinejudge.org/external/3/340img2.gif\" width\u003d\"59\" /\u003e , and are to determine the hint. A hint consists of a pair of numbers determined as follows.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tA \u003ci\u003ematch\u003c/i\u003e is a pair (\u003ci\u003ei\u003c/i\u003e,\u003ci\u003ej\u003c/i\u003e), \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline41\" height\u003d\"25\" src\u003d\"http://uva.onlinejudge.org/external/3/340img3.gif\" width\u003d\"70\" /\u003e and \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline43\" height\u003d\"25\" src\u003d\"http://uva.onlinejudge.org/external/3/340img4.gif\" width\u003d\"73\" /\u003e , such that \u003cimg align\u003d\"MIDDLE\" alt\u003d\"tex2html_wrap_inline45\" height\u003d\"17\" src\u003d\"http://uva.onlinejudge.org/external/3/340img5.gif\" width\u003d\"49\" /\u003e . Match (\u003ci\u003ei\u003c/i\u003e,\u003ci\u003ej\u003c/i\u003e) is called \u003ci\u003estrong\u003c/i\u003e when \u003ci\u003ei\u003c/i\u003e \u003d \u003ci\u003ej\u003c/i\u003e, and is called \u003ci\u003eweak\u003c/i\u003e otherwise. Two matches (\u003ci\u003ei\u003c/i\u003e,\u003ci\u003ej\u003c/i\u003e) and (\u003ci\u003ep\u003c/i\u003e,\u003ci\u003eq\u003c/i\u003e) are called \u003ci\u003eindependent\u003c/i\u003e when \u003ci\u003ei\u003c/i\u003e \u003d \u003ci\u003ep\u003c/i\u003e if and only if \u003ci\u003ej\u003c/i\u003e \u003d \u003ci\u003eq\u003c/i\u003e. A set of matches is called \u003ci\u003eindependent\u003c/i\u003e when all of its members are pairwise independent.\u003c/p\u003e\r\n\u003cp\u003e\r\n\tDesigner chooses an independent set \u003ci\u003eM\u003c/i\u003e of matches for which the total number of matches and the number of strong matches are both maximal. The hint then consists of the number of strong followed by the number of weak matches in \u003ci\u003eM\u003c/i\u003e. Note that these numbers are uniquely determined by the secret code and the guess. If the hint turns out to be (\u003ci\u003en\u003c/i\u003e,0), then the guess is identical to the secret code.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003clink href\u003d\"http://uva.onlinejudge.org/external/3/htmlatex.css\" rel\u003d\"STYLESHEET\" /\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv\u003e\r\n\tThe input will consist of data for a number of games. The input for each game begins with an integer specifying\u0026nbsp;\u003ci\u003eN\u003c/i\u003e\u0026nbsp;(the length of the code). Following these will be the secret code, represented as\u0026nbsp;\u003ci\u003eN\u003c/i\u003e\u0026nbsp;integers, which we will limit to the range 1 to 9. There will then follow an arbitrary number of guesses, each also represented as\u0026nbsp;\u003ci\u003eN\u003c/i\u003e\u0026nbsp;integers, each in the range 1 to 9. Following the last guess in each game will be\u0026nbsp;\u003ci\u003eN\u003c/i\u003e\u0026nbsp;zeroes; these zeroes are not to be considered as a guess.\u003c/div\u003e\r\n\u003cdiv\u003e\r\n\t\u003cp\u003e\r\n\t\tFollowing the data for the first game will appear data for the second game (if any) beginning with a new value for\u0026nbsp;\u003ci\u003eN\u003c/i\u003e. The last game in the input will be followed by a single zero (when a value for\u0026nbsp;\u003ci\u003eN\u003c/i\u003e\u0026nbsp;would normally be specified). The maximum value for\u0026nbsp;\u003ci\u003eN\u003c/i\u003e\u0026nbsp;will be 1000.\u003c/p\u003e\r\n\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tThe output for each game should list the hints that would be generated for each guess, in order, one hint per line. Each hint should be represented as a pair of integers enclosed in parentheses and separated by a comma. The entire list of hints for each game should be prefixed by a heading indicating the game number; games are numbered sequentially starting with 1. Look at the samples below for the\u0026nbsp;\u003cem\u003eexact\u003c/em\u003e\u0026nbsp;format.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\r\n4\r\n1 3 5 5\r\n1 1 2 3\r\n4 3 3 5\r\n6 5 5 1\r\n6 1 3 5\r\n1 3 5 5\r\n0 0 0 0\r\n10\r\n1 2 2 2 4 5 6 6 6 9\r\n1 2 3 4 5 6 7 8 9 1\r\n1 1 2 2 3 3 4 4 5 5\r\n1 2 1 3 1 5 1 6 1 9\r\n1 2 2 5 5 5 6 6 6 7\r\n0 0 0 0 0 0 0 0 0 0\r\n0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\r\nGame 1:\r\n (1,1)\r\n (2,0)\r\n (1,2)\r\n (1,2)\r\n (4,0)\r\nGame 2:\r\n (2,4)\r\n (3,2)\r\n (5,0)\r\n (7,0)\u003c/pre\u003e"}}]}