{"raw_statement":[{"iden":"problem statement","content":"There is a grid with $H$ horizontal rows and $W$ vertical columns. For two integers $i$ and $j$ such that $1 \\leq i \\leq H$ and $1 \\leq j \\leq W$, the square at the $i$\\-th row from the top and $j$\\-th column from the left (which we denote by $(i, j)$) has an integer $A_{i, j}$ written on it.\nTakahashi is currently at $(1,1)$. From now on, he repeats moving to an adjacent square to the right of or below his current square until he reaches $(H, W)$. When he makes a move, he is not allowed to go outside the grid.\nTakahashi will be happy if the integers written on the squares he visits (including initial $(1, 1)$ and final $(H, W)$) are distinct. Find the number of his possible paths that make him happy."},{"iden":"constraints","content":"*   $2 \\leq H, W \\leq 10$\n*   $1 \\leq A_{i, j} \\leq 10^9$\n*   All values in the input are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$H$ $W$\n$A_{1, 1}$ $A_{1, 2}$ $\\ldots$ $A_{1, W}$\n$A_{2, 1}$ $A_{2, 2}$ $\\ldots$ $A_{2, W}$\n$\\vdots$\n$A_{H, 1}$ $A_{H, 2}$ $\\ldots$ $A_{H, W}$"},{"iden":"sample input 1","content":"3 3\n3 2 2\n2 1 3\n1 5 4"},{"iden":"sample output 1","content":"3\n\nThere are six possible paths:\n\n*   $(1, 1) \\rightarrow (1, 2) \\rightarrow (1, 3) \\rightarrow (2, 3) \\rightarrow (3, 3)$: the integers written on the squares he visits are $3, 2, 2, 3, 4$, so he **will not** be happy.\n*   $(1, 1) \\rightarrow (1, 2) \\rightarrow (2, 2) \\rightarrow (2, 3) \\rightarrow (3, 3)$: the integers written on the squares he visits are $3, 2, 1, 3, 4$, so he **will not** be happy.\n*   $(1, 1) \\rightarrow (1, 2) \\rightarrow (2, 2) \\rightarrow (3, 2) \\rightarrow (3, 3)$: the integers written on the squares he visits are $3, 2, 1, 5, 4$, so he **will** be happy.\n*   $(1, 1) \\rightarrow (2, 1) \\rightarrow (2, 2) \\rightarrow (2, 3) \\rightarrow (3, 3)$: the integers written on the squares he visits are $3, 2, 1, 3, 4$, so he **will not** be happy.\n*   $(1, 1) \\rightarrow (2, 1) \\rightarrow (2, 2) \\rightarrow (3, 2) \\rightarrow (3, 3)$: the integers written on the squares he visits are $3, 2, 1, 5, 4$, so he **will** be happy.\n*   $(1, 1) \\rightarrow (2, 1) \\rightarrow (3, 1) \\rightarrow (3, 2) \\rightarrow (3, 3)$: the integers written on the squares he visits are $3, 2, 1, 5, 4$, so he **will** be happy.\n\nThus, the third, fifth, and sixth paths described above make him happy."},{"iden":"sample input 2","content":"10 10\n1 2 3 4 5 6 7 8 9 10\n11 12 13 14 15 16 17 18 19 20\n21 22 23 24 25 26 27 28 29 30\n31 32 33 34 35 36 37 38 39 40\n41 42 43 44 45 46 47 48 49 50\n51 52 53 54 55 56 57 58 59 60\n61 62 63 64 65 66 67 68 69 70\n71 72 73 74 75 76 77 78 79 80\n81 82 83 84 85 86 87 88 89 90\n91 92 93 94 95 96 97 98 99 100"},{"iden":"sample output 2","content":"48620\n\nIn this example, every possible path makes him happy."}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}