{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003clink href\u003d\"css/light_oj.css\" rel\u003d\"stylesheet\" type\u003d\"text/css\" /\u003e\r\n\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tA binary matrix is an \u003cb\u003em x n\u003c/b\u003e matrix consisting of only zeroes and ones. Now you are given \u003cb\u003em\u003c/b\u003e integers, \u003cb\u003e\u003cspan data-scayt_word\u003d\"ith\" data-scaytid\u003d\"1\"\u003ei\u003csup\u003eth\u003c/sup\u003e\u003c/span\u003e\u003c/b\u003e integer indicating the summation of the values of cells in \u003cb\u003e\u003cspan data-scayt_word\u003d\"ith\" data-scaytid\u003d\"2\"\u003ei\u003csup\u003eth\u003c/sup\u003e\u003c/span\u003e\u003c/b\u003e row. You are also given \u003cb\u003en\u003c/b\u003e integers, \u003cb\u003e\u003cspan data-scayt_word\u003d\"ith\" data-scaytid\u003d\"3\"\u003ei\u003csup\u003eth\u003c/sup\u003e\u003c/span\u003e\u003c/b\u003e integer indicating the summation of the values of cells in \u003cb\u003e\u003cspan data-scayt_word\u003d\"jth\" data-scaytid\u003d\"5\"\u003ej\u003csup\u003eth\u003c/sup\u003e\u003c/span\u003e\u003c/b\u003e column.\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tYour task is to generate the binary matrix. As there can be multiple solutions, we want the solution which is lexicographically smallest. To compare two solutions, we first find the cell (topmost, then leftmost) where the solutions differ; then the solution which contains 0 in that cell is lexicographically smaller. So,\u003c/p\u003e\r\n\u003cdiv align\u003d\"center\"\u003e\r\n\t\u003ctable border\u003d\"0\" cellpadding\u003d\"0\" cellspacing\u003d\"0\" class\u003d\"MsoTableGrid\" style\u003d\"margin-left:1.7in;border-collapse:collapse;border:none\"\u003e\r\n\t\t\u003ctbody\u003e\r\n\t\t\t\u003ctr\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:37.2pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"50\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\" style\u003d\"margin-bottom:0in;margin-bottom:.0001pt\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e001\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:21.3pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"28\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\" style\u003d\"margin-bottom:0in;margin-bottom:.0001pt\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e\u0026nbsp;\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:27.7pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"37\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\" style\u003d\"margin-bottom:0in;margin-bottom:.0001pt\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e001\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\u003c/tr\u003e\r\n\t\t\t\u003ctr\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:37.2pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"50\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\" style\u003d\"margin-bottom:0in;margin-bottom:.0001pt\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e010\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:21.3pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"28\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\" style\u003d\"margin-bottom:0in;margin-bottom:.0001pt\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e\u0026lt;\u0026nbsp;\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:27.7pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"37\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\" style\u003d\"margin-bottom:0in;margin-bottom:.0001pt\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e100\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\u003c/tr\u003e\r\n\t\t\t\u003ctr\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:37.2pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"50\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e100\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:21.3pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"28\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e\u0026nbsp;\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\t\u003ctd style\u003d\"width:27.7pt;padding:0in 5.4pt 0in 5.4pt\" valign\u003d\"top\" width\u003d\"37\"\u003e\r\n\t\t\t\t\t\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\t\t\t\t\t\u003cb\u003e010\u003c/b\u003e\u003c/p\u003e\r\n\t\t\t\t\u003c/td\u003e\r\n\t\t\t\u003c/tr\u003e\r\n\t\t\u003c/tbody\u003e\r\n\t\u003c/table\u003e\r\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tInput starts with an integer \u003cb\u003eT (\u003c/b\u003e\u003cb\u003e\u0026le; 125)\u003c/b\u003e, denoting the number of test cases.\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tEach case starts with a line containing two integers: \u003cb\u003em\u003c/b\u003e and \u003cb\u003en (1 \u0026le; m, n \u0026le; 50)\u003c/b\u003e. The next line contains \u003cb\u003em\u003c/b\u003e integers, separated by a single space, denoting the row sums. The next line contains n integers, separated by spaces, denoting the column sum. All the integers will be between \u003cb\u003e0\u003c/b\u003e and \u003cb\u003e50 \u003c/b\u003e(inclusive).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tFor each case, print the case number first. Then if there is no solution, then print \u003cb\u003e\u0026#39;impossible\u0026#39;\u003c/b\u003e on the same line. Otherwise, from the next line, print \u003cb\u003em\u003c/b\u003e lines each having \u003cb\u003en\u003c/b\u003e characters denoting the binary matrix as stated above.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cp class\u003d\"MsoNormal\" style\u003d\"margin-bottom:0in;margin-bottom:.0001pt\"\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\t5\u003c/p\u003e\r\n\u003cp\u003e\r\n\t3 3\u003c/p\u003e\r\n\u003cp\u003e\r\n\t1 1 1\u003c/p\u003e\r\n\u003cp\u003e\r\n\t1 1 1\u003c/p\u003e\r\n\u003cp\u003e\r\n\t3 3\u003c/p\u003e\r\n\u003cp\u003e\r\n\t1 1 2\u003c/p\u003e\r\n\u003cp\u003e\r\n\t2 2 1\u003c/p\u003e\r\n\u003cp\u003e\r\n\t2 3\u003c/p\u003e\r\n\u003cp\u003e\r\n\t30 30\u003c/p\u003e\r\n\u003cp\u003e\r\n\t30 20 10\u003c/p\u003e\r\n\u003cp\u003e\r\n\t2 9\u003c/p\u003e\r\n\u003cp\u003e\r\n\t5 5\u003c/p\u003e\r\n\u003cp\u003e\r\n\t1 1 2 1 1 1 1 1 1\u003c/p\u003e\r\n\u003cp\u003e\r\n\t3 3\u003c/p\u003e\r\n\u003cp\u003e\r\n\t1 2 3\u003c/p\u003e\r\n\u003cp\u003e\r\n\t3 2 1\u003c/p\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cp class\u003d\"MsoNormal\" style\u003d\"margin-bottom:0in;margin-bottom:.0001pt\"\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tCase 1:\u003c/p\u003e\r\n\u003cp\u003e\r\n\t001\u003c/p\u003e\r\n\u003cp\u003e\r\n\t010\u003c/p\u003e\r\n\u003cp\u003e\r\n\t100\u003c/p\u003e\r\n\u003cp\u003e\r\n\tCase 2: impossible\u003c/p\u003e\r\n\u003cp\u003e\r\n\tCase 3: impossible\u003c/p\u003e\r\n\u003cp\u003e\r\n\tCase 4:\u003c/p\u003e\r\n\u003cp\u003e\r\n\t001001111\u003c/p\u003e\r\n\u003cp\u003e\r\n\t111110000\u003c/p\u003e\r\n\u003cp\u003e\r\n\tCase 5:\u003c/p\u003e\r\n\u003cp\u003e\r\n\t100\u003c/p\u003e\r\n\u003cp\u003e\r\n\t110\u003c/p\u003e\r\n\u003cp\u003e\r\n\t111\u003c/p\u003e"}}]}