{"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\u003eOne day Alex decided to remember childhood when computers were not too powerful and lots of people played only default games. Alex enjoyed playing Minesweeper that time. He imagined that he saved world from bombs planted by terrorists, but he rarely won.\u003c/p\u003e\u003cp\u003eAlex has grown up since then, so he easily wins the most difficult levels. This quickly bored him, and he thought: what if the computer gave him invalid fields in the childhood and Alex could not win because of it?\u003c/p\u003e\u003cp\u003eHe needs your help to check it.\u003c/p\u003e\u003cp\u003eA Minesweeper field is a rectangle $$$n \\times m$$$, where each cell is either empty, or contains a digit from $$$1$$$ to $$$8$$$, or a bomb. The field is valid if for each cell: \u003c/p\u003e\u003cul\u003e \u003cli\u003e if there is a digit $$$k$$$ in the cell, then exactly $$$k$$$ neighboring cells have bombs. \u003c/li\u003e\u003cli\u003e if the cell is empty, then all neighboring cells have no bombs. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eTwo cells are neighbors if they have a common side or a corner (i.\u0026nbsp;e. a cell has at most $$$8$$$ neighboring cells).\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 100$$$) — the sizes of the field.\u003c/p\u003e\u003cp\u003eThe next $$$n$$$ lines contain the description of the field. Each line contains $$$m$$$ characters, each of them is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e.\u003c/span\u003e\" (if this cell is empty), \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e*\u003c/span\u003e\" (if there is bomb in this cell), or a digit from $$$1$$$ to $$$8$$$, inclusive.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\", if the field is valid and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\" otherwise.\u003c/p\u003e\u003cp\u003eYou can choose the case (lower or upper) for each letter arbitrarily.\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\u003e3 3\n111\n1*1\n111\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\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 4\n*.*.\n1211\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eNO\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 second example the answer is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\" because, if the positions of the bombs are preserved, the first line of the field should be \u003cspan class\u003d\"tex-font-style-tt\"\u003e*2*1\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eYou can read more about Minesweeper in \u003ca href\u003d\"https://en.wikipedia.org/wiki/Minesweeper_(video_game)\"\u003eWikipedia\u0027s article\u003c/a\u003e.\u003c/p\u003e"}}]}