{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eDora loves adventures quite a lot. During some journey she encountered an amazing city, which is formed by $$$n$$$ streets along the Eastern direction and $$$m$$$ streets across the Southern direction. Naturally, this city has $$$nm$$$ intersections. At any intersection of $$$i$$$-th Eastern street and $$$j$$$-th Southern street there is a monumental skyscraper. Dora instantly became curious and decided to explore the heights of the city buildings.\u003c/p\u003e\u003cp\u003eWhen Dora passes through the intersection of the $$$i$$$-th Eastern and $$$j$$$-th Southern street she examines those two streets. After Dora learns the heights of all the skyscrapers on those two streets she wonders: how one should reassign heights to the skyscrapers on those two streets, so that the maximum height would be as small as possible and the result of comparing the heights of any two skyscrapers on one street wouldn\u0027t change.\u003c/p\u003e\u003cp\u003eFormally, on every of $$$nm$$$ intersections Dora solves an independent problem. She sees $$$n + m - 1$$$ skyscrapers and for each of them she knows its real height. Moreover, any two heights can be compared to get a result \"greater\", \"smaller\" or \"equal\". Now Dora wants to select some integer $$$x$$$ and assign every skyscraper a height from $$$1$$$ to $$$x$$$. When assigning heights, Dora wants to preserve the relative order of the skyscrapers in both streets. That is, the result of any comparison of heights of two skyscrapers in the current Eastern street shouldn\u0027t change and the result of any comparison of heights of two skyscrapers in current Southern street shouldn\u0027t change as well. Note that skyscrapers located on the Southern street are not compared with skyscrapers located on the Eastern street only. However, the skyscraper located at the streets intersection can be compared with both Southern and Eastern skyscrapers. For every intersection Dora wants to \u003cspan class\u003d\"tex-font-style-bf\"\u003eindependently\u003c/span\u003e calculate the minimum possible $$$x$$$.\u003c/p\u003e\u003cp\u003eFor example, if the intersection and the two streets corresponding to it look as follows:\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" height\u003d\"140px\" src\u003d\"CDN_BASE_URL/e8d63dbd33e5963303338b11492d57c2?v\u003d1715406022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" width\u003d\"278px\"\u003e \u003c/center\u003e\u003cp\u003eThen it is optimal to replace the heights of the skyscrapers as follows (note that all comparisons \"less\", \"equal\", \"greater\" inside the Eastern street and inside the Southern street are preserved)\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" height\u003d\"136px\" src\u003d\"CDN_BASE_URL/4832064961b9953c171e54f840c0ed06?v\u003d1715406022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" width\u003d\"212px\"\u003e \u003c/center\u003e\u003cp\u003eThe largest used number is $$$5$$$, hence the answer for this intersection would be $$$5$$$.\u003c/p\u003e\u003cp\u003eHelp Dora to compute the answers for each intersection.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 1000$$$)\u0026nbsp;— the number of streets going in the Eastern direction and the number of the streets going in Southern direction.\u003c/p\u003e\u003cp\u003eEach of the following $$$n$$$ lines contains $$$m$$$ integers $$$a_{i,1}$$$, $$$a_{i,2}$$$, ..., $$$a_{i,m}$$$ ($$$1 \\le a_{i,j} \\le 10^9$$$). The integer $$$a_{i,j}$$$, located on $$$j$$$-th position in the $$$i$$$-th line denotes the height of the skyscraper at the intersection of the $$$i$$$-th Eastern street and $$$j$$$-th Southern direction.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint $$$n$$$ lines containing $$$m$$$ integers each. The integer $$$x_{i,j}$$$, located on $$$j$$$-th position inside the $$$i$$$-th line is an answer for the problem at the intersection of $$$i$$$-th Eastern street and $$$j$$$-th Southern street.\u003c/p\u003e"}},{"title":"Examples","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\u003e2 3\n1 2 1\n2 1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2 2 2 \n2 2 2 \n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","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\u003e2 2\n1 2\n3 4\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2 3 \n3 2 \n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first example, it\u0027s not possible to decrease the maximum used height for the problem at any intersection, hence we don\u0027t have to change any heights.\u003c/p\u003e\u003cp\u003eIn the second example, the answers are as follows: \u003c/p\u003e\u003cul\u003e \u003cli\u003e For the intersection of the first line and the first column \u003cimg class\u003d\"tex-graphics\" height\u003d\"72px\" src\u003d\"CDN_BASE_URL/58fb9690fff2eff159427b28b4659e3e?v\u003d1715406022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" width\u003d\"212px\"\u003e\u003c/li\u003e\u003cli\u003e For the intersection of the first line and the second column \u003cimg class\u003d\"tex-graphics\" height\u003d\"72px\" src\u003d\"CDN_BASE_URL/18d2fac33c51295e414f0c48b6b5bae9?v\u003d1715406022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" width\u003d\"215px\"\u003e\u003c/li\u003e\u003cli\u003e For the intersection of the second line and the first column \u003cimg class\u003d\"tex-graphics\" height\u003d\"72px\" src\u003d\"CDN_BASE_URL/15fbd95c7430d7c6bc1b11805a9c6d9a?v\u003d1715406022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" width\u003d\"212px\"\u003e\u003c/li\u003e\u003cli\u003e For the intersection of the second line and the second column \u003cimg class\u003d\"tex-graphics\" height\u003d\"72px\" src\u003d\"CDN_BASE_URL/be6d5bcda95398c9ae3021dde48310bf?v\u003d1715406022\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\" width\u003d\"212px\"\u003e \u003c/li\u003e\u003c/ul\u003e"}}]}