{"trustable":true,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eLittle Q is crazy about graph theory, and now he creates a game about graphs and trees.\u003cbr\u003eThere is a bi-directional graph with $n$ nodes, labeled from 0 to $n-1$. Every edge has its length, which is a positive integer ranged from 1 to 9.\u003cbr\u003eNow, Little Q wants to delete some edges (or delete nothing) in the graph to get a new graph, which satisfies the following requirements:\u003cbr\u003e(1) The new graph is a tree with $n-1$ edges.\u003cbr\u003e(2) For every vertice $v(0\u0026lt;v\u0026lt;n)$, the distance between 0 and $v$ on the tree is equal to the length of shortest path from 0 to $v$ in the original graph.\u003cbr\u003eLittle Q wonders the number of ways to delete edges to get such a satisfied graph. If there exists an edge between two nodes $i$ and $j$, while in another graph there isn\u0027t such edge, then we regard the two graphs different.\u003cbr\u003eSince the answer may be very large, please print the answer modulo $10^9+7$.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input contains several test cases, no more than 10 test cases.\u003cbr\u003eIn each test case, the first line contains an integer $n(1\\leq n\\leq 50)$, denoting the number of nodes in the graph.\u003cbr\u003eIn the following $n$ lines, every line contains a string with $n$ characters. These strings describes the adjacency matrix of the graph. Suppose the $j$-th number of the $i$-th line is $c(0\\leq c\\leq 9)$, if $c$ is a positive integer, there is an edge between $i$ and $j$ with length of $c$, if $c\u003d0$, then there isn\u0027t any edge between $i$ and $j$.\u003cbr\u003eThe input data ensure that the $i$-th number of the $i$-th line is always 0, and the $j$-th number of the $i$-th line is always equal to the $i$-th number of the $j$-th line."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print a single line containing a single integer, denoting the answer modulo $10^9+7$."}},{"title":"Sample","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\r\n01\r\n10\r\n4\r\n0123\r\n1012\r\n2101\r\n3210\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n6\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}