{"raw_statement":[{"iden":"statement","content":"Jaber is a policeman of a city that can be described by a grid of size $n times m$, where every cell in that grid contains a house of one of the civilians.\n\nAt night every person in the city should go sleep and should turn the lights of their house off.\n\nAs a policeman Jaber should check the lights of every house in that city.\n\nJaber checks every row and every column in that city exactly once, in the order written on a paper with Jaber.\n\nEvery time Jaber checks a row or a column, he counts the number of houses that has their lights turned on. If he found more than one house with lights turned on he becomes sad.\n\nAlso every time he checks a row or a column, he makes sure that every house in that row or column will turn off their lights.\n\nAyoub doesn't remember exactly the description of the city, but he remembers in every row the number of houses that will have their lights on.\n\nAyoub wants to know if it is possible to have a city with that description and has at least one correct order.\n\nThe first line contains two integers $n$ and $m$ $(1 <= n, m <= 1000)$.\n\nThe second line contains $n$ integers, the $i_{t h}$ one is $a_i$ $(0 <= a_i <= m)$, which is the number of houses that will have their lights on in the $i_{t h}$ row.\n\nIf there is no possible answer print _NO_ on a line, otherwise print _YES_.\n\nif there is an answer you should print $n$ lines, the $i_{t h}$ line should contain $m$ characters, the $j_{t h}$ character should be _1_ if the house in the $i_{t h}$ row $j_{t h}$ column has their lights on, and _0_ otherwise.\n\nmake sure that the number of _1_'s in the $i_{t h}$ row is equal to $a_i$.\n\nthen you should print $n + m$ lines, which is a correct order of rows and columns that won't make Jaber sad.\n\nin every line you should print \n\n_row_ $x$ or _col_ $x$.\n\nmake sure that every row and column appears exactly once.\n\n"},{"iden":"input","content":"The first line contains two integers $n$ and $m$ $(1 <= n, m <= 1000)$.The second line contains $n$ integers, the $i_{t h}$ one is $a_i$ $(0 <= a_i <= m)$, which is the number of houses that will have their lights on in the $i_{t h}$ row."},{"iden":"output","content":"If there is no possible answer print _NO_ on a line, otherwise print _YES_.if there is an answer you should print $n$ lines, the $i_(t h)$ line should contain $m$ characters, the $j_(t h)$ character should be _1_ if the house in the $i_(t h)$ row $j_(t h)$ column has their lights on, and _0_ otherwise.make sure that the number of _1_'s in the $i_(t h)$ row is equal to $a_i$.then you should print $n + m$ lines, which is a correct order of rows and columns that won't make Jaber sad.in every line you should print _row_ $x$ or _col_ $x$.make sure that every row and column appears exactly once."},{"iden":"examples","content":"Input4 4\n1 0 0 0\nOutputYES\n1000\n0000\n0000\n0000\nrow 1\ncol 1\nrow 2\ncol 2\nrow 3\ncol 3\nrow 4\ncol 4\nInput4 4\n2 1 1 1\nOutputYES\n1010\n1000\n0100\n0001\ncol 3\nrow 1\ncol 1\nrow 2\ncol 2\nrow 3\nrow 4\ncol 4\n"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, m \\in \\mathbb{Z}^+ $ be the dimensions of the grid.  \nLet $ \\mathbf{a} = (a_1, a_2, \\dots, a_n) \\in \\mathbb{Z}_{\\geq 0}^n $, where $ 0 \\leq a_i \\leq m $, denote the number of lights turned on in row $ i $.  \n\nLet $ G \\in \\{0,1\\}^{n \\times m} $ be a binary matrix where $ G_{i,j} = 1 $ iff the light at row $ i $, column $ j $ is on.  \nLet $ \\mathcal{O} $ be a sequence of $ n + m $ operations, each being either _row $ i $| or _col $ j $|, such that each row and each column appears exactly once.\n\n**Constraints**  \n1. For each row $ i \\in \\{1, \\dots, n\\} $: $ \\sum_{j=1}^m G_{i,j} = a_i $.  \n2. For each column $ j \\in \\{1, \\dots, m\\} $: $ \\sum_{i=1}^n G_{i,j} = b_j $ for some $ \\mathbf{b} \\in \\mathbb{Z}_{\\geq 0}^m $ (to be determined).  \n3. There exists an order $ \\mathcal{O} $ such that when processing operations sequentially:  \n   - Upon processing a row $ i $, the number of 1s in row $ i $ at that moment is $ \\leq 1 $.  \n   - Upon processing a column $ j $, the number of 1s in column $ j $ at that moment is $ \\leq 1 $.  \n   - After processing any row or column, all entries in it are set to 0.  \n\n**Objective**  \nDetermine whether such a matrix $ G $ and order $ \\mathcal{O} $ exist.  \nIf yes, output $ G $ and $ \\mathcal{O} $. Otherwise, output \"NO\".","simple_statement":"You are given an n×m grid. Each cell is a house with light on (1) or off (0).  \n\nYou are told how many lights are on in each row: row i has exactly a_i lights on.  \n\nJaber checks rows and columns one by one, in some order.  \nEach time he checks a row or column, he counts how many lights are ON.  \nIf he sees 2 or more lights ON in that row/column, he gets sad.  \nThen he turns ALL lights OFF in that row/column.  \n\nYou must find:  \n1. A valid grid (with a_i ones in row i)  \n2. An order of n+m checks (each row and column exactly once) so that Jaber NEVER sees 2 or more lights on in any check.  \n\nIf possible, print:  \n- \"YES\"  \n- The grid (n lines of m characters, '1' or '0')  \n- The order: n+m lines, each is \"_row x_\" or \"_col x_\"  \n\nIf impossible, print \"NO\".","has_page_source":false}