{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eWe have a grid with \u003cvar\u003e\\(H\\)\u003c/var\u003e horizontal rows and \u003cvar\u003e\\(W\\)\u003c/var\u003e vertical columns of squares.\r\nSquare \u003cvar\u003e\\((i,j)\\)\u003c/var\u003e, which is at the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th row from the top and \u003cvar\u003e\\(j\\)\u003c/var\u003e-th column from the left, is \u003cem\u003ewall\u003c/em\u003e if \u003cvar\u003e\\(S_{ij}\\)\u003c/var\u003e is \u003ccode\u003e#\u003c/code\u003e and \u003cem\u003eroad\u003c/em\u003e if \u003cvar\u003e\\(S_{ij}\\)\u003c/var\u003e is \u003ccode\u003e.\u003c/code\u003e.\u003c/p\u003e\r\n\u003cp\u003eThere is a queen, the chess piece, at Square \u003cvar\u003e\\((1, 1)\\)\u003c/var\u003e. In one move, it can move any number of squares to the right, downwards, or diagonally to the lower right to a road square without jumping over wall squares.\u003c/p\u003e\r\n\u003cp\u003eIn how many ways can the queen travel from Square \u003cvar\u003e\\((1, 1)\\)\u003c/var\u003e to Square \u003cvar\u003e\\((H, W)\\)\u003c/var\u003e? Find the count modulo \u003cvar\u003e\\((10^9+7)\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eHere, two ways to travel are considered different if and only if there exists \u003cvar\u003e\\(i\\)\u003c/var\u003e such that the position of the queen after the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th move is different in those two ways.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(2 \\leq H,W \\leq 2000\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(S_{ij}\\)\u003c/var\u003e is \u003ccode\u003e#\u003c/code\u003e or \u003ccode\u003e.\u003c/code\u003e.\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(S_{11}\\)\u003c/var\u003e and \u003cvar\u003e\\(S_{HW}\\)\u003c/var\u003e are \u003ccode\u003e.\u003c/code\u003e.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(H\\)\u003c/var\u003e \u003cvar\u003e\\(W\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(S_{11}\\ldots S_{1W}\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(\\vdots\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(S_{H1}\\ldots S_{HW}\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003ePrint the number of ways, modulo \u003cvar\u003e\\((10^9+7)\\)\u003c/var\u003e, in which the queen can travel from Square \u003cvar\u003e\\((1, 1)\\)\u003c/var\u003e to Square \u003cvar\u003e\\((H, W)\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 1","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\r\n...\r\n.#.\r\n...\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e10\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eThere are \u003cvar\u003e\\(10\\)\u003c/var\u003e ways to travel, as follows:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (1,2)\\to (1,3)\\to (2,3)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (1,2)\\to (1,3)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (1,2)\\to (2,3)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (1,3)\\to (2,3)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (1,3)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (2,1)\\to (3,1)\\to (3,2)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (2,1)\\to (3,1)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (2,1)\\to (3,2)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (3,1)\\to (3,2)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\((1,1)\\to (3,1)\\to (3,3)\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 2","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\u003e4 4\r\n...#\r\n....\r\n..#.\r\n....\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e84\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eFrom \u003cvar\u003e\\((1,1)\\)\u003c/var\u003e, the queen can move to \u003cvar\u003e\\((1,2)\\)\u003c/var\u003e, \u003cvar\u003e\\((1,3)\\)\u003c/var\u003e, \u003cvar\u003e\\((2,1)\\)\u003c/var\u003e, \u003cvar\u003e\\((2,2)\\)\u003c/var\u003e, \u003cvar\u003e\\((3,1)\\)\u003c/var\u003e, or \u003cvar\u003e\\((4,1)\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eOne possible path to \u003cvar\u003e\\((4,4)\\)\u003c/var\u003e is \u003cvar\u003e\\((1,1)\\to (3,1)\\to (3,2)\\to (4,3)\\to (4,4)\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 3","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\u003e8 10\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n..........\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e13701937\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eFind the count modulo \u003cvar\u003e\\((10^9+7)\\)\u003c/var\u003e.\u003c/p\u003e\u003c/section\u003e\r\n"}}]}