{"raw_statement":[{"iden":"statement","content":"At the time free of games Andrey processes images. Most of all he likes to process grayscale images. Each pixel on a grayscale image has a brightness which is the integer from 0 to 109, inclusively. The closer the brightness to zero, the darker is this pixel; zero brightness corresponds to the black color and 109 — to the white. Andrey calls such pictures _colored_.\n\nWhen processing colored picture, Andrey chooses an integer t from 0 to 109, inclusively, and creates a new image consisting of only two colors: black and while (he denotes them as 0 and 1, correspondingly). He calls such images _monochrome_.\n\nThe principle of creating monochrome images is very simple: Andrey looks at each pixel of the initial colored image and, if the brightness of this pixel is strictly less that t, this pixel will be black on the monochrome image, otherwise it will be white.\n\nYou are given k monochrome images. You are to determine if they all could be the result of processing the same colored image, and if they could, which exactly colored image and values t1, ..., tk could be used.\n\nThe first line contains three positive integers k, n and m (1 ≤ k·n·m ≤ 200000) — the amount of images and their sizes.\n\nThen k blocks describing monochrome images follow. Each block starts from the empty line, followed by the description of the image: n lines of m characters each. These characters can be either «_0_», which denotes the black color, or «_1_», which corresponds to the white color.\n\nIf there is no such colored image that all k given monochrome images can be the result of its processing, output «_IMPOSSIBLE_».\n\nOtherwise, in the first n lines output the matrix n × m, each element of which is the integer from 0 to 109 and equals to the brightness of the corresponding pixel of the colored image. Numbers should be separated by spaces.\n\nAfter the matrix in the next line output k numbers t1, ..., tk (0 ≤ ti ≤ 109) used to obtain the corresponding monochrome images.\n\nIf there are several possible solutions, output any of them.\n\n"},{"iden":"input","content":"The first line contains three positive integers k, n and m (1 ≤ k·n·m ≤ 200000) — the amount of images and their sizes.Then k blocks describing monochrome images follow. Each block starts from the empty line, followed by the description of the image: n lines of m characters each. These characters can be either «_0_», which denotes the black color, or «_1_», which corresponds to the white color."},{"iden":"output","content":"If there is no such colored image that all k given monochrome images can be the result of its processing, output «_IMPOSSIBLE_».Otherwise, in the first n lines output the matrix n × m, each element of which is the integer from 0 to 109 and equals to the brightness of the corresponding pixel of the colored image. Numbers should be separated by spaces.After the matrix in the next line output k numbers t1, ..., tk (0 ≤ ti ≤ 109) used to obtain the corresponding monochrome images.If there are several possible solutions, output any of them."},{"iden":"examples","content":"Input2 3 3  011000110  111100111Output2 4 52 1 04 7 24 2Input2 3 3  011000110  100101001OutputIMPOSSIBLE"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ k, n, m \\in \\mathbb{Z}^+ $ with $ 1 \\leq k \\cdot n \\cdot m \\leq 200000 $.  \nLet $ I_1, I_2, \\dots, I_k $ be $ k $ monochrome images, each of size $ n \\times m $, where $ I_j = (b_{j,i,\\ell}) \\in \\{0,1\\}^{n \\times m} $ for $ j \\in \\{1, \\dots, k\\} $, $ i \\in \\{1, \\dots, n\\} $, $ \\ell \\in \\{1, \\dots, m\\} $.  \nLet $ A = (a_{i,\\ell}) \\in \\{0, 1, \\dots, 10^9\\}^{n \\times m} $ be the unknown colored image.  \nLet $ t_1, t_2, \\dots, t_k \\in \\{0, 1, \\dots, 10^9\\} $ be the thresholds used for each monochrome image.\n\n**Constraints**  \nFor each $ j \\in \\{1, \\dots, k\\} $, and for all $ i \\in \\{1, \\dots, n\\} $, $ \\ell \\in \\{1, \\dots, m\\} $:  \n$$\nb_{j,i,\\ell} = \n\\begin{cases}\n0 & \\text{if } a_{i,\\ell} < t_j \\\\\n1 & \\text{if } a_{i,\\ell} \\geq t_j\n\\end{cases}\n$$\n\n**Objective**  \nDetermine if there exists a matrix $ A $ and thresholds $ t_1, \\dots, t_k $ satisfying the above constraints.  \nIf yes, output any such $ A $ and $ t_1, \\dots, t_k $.  \nIf no, output \"IMPOSSIBLE\".","simple_statement":"You are given k black-and-white images of size n×m.  \nEach image was made by taking a single colored image (with pixel values from 0 to 10^9) and a threshold t:  \n- Pixels < t become black (0)  \n- Pixels ≥ t become white (1)  \n\nYou need to find:  \n1. A colored image (n×m matrix of integers from 0 to 10^9)  \n2. k thresholds t1, t2, ..., tk  \n\nSuch that each black-and-white image matches the colored image using its threshold.  \n\nIf impossible, output \"IMPOSSIBLE\".  \nIf possible, output the colored image and the k thresholds.","has_page_source":false}