{"trustable":false,"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":"\u003cp\u003e有$n$只鱼,每只鱼都有一个权值 $value_i$\u003c/p\u003e\n\u003cp\u003e每只鱼都认为自己是雄性,并且它们会去攻击自己认为是雌性的其他鱼\u003c/p\u003e\n\u003cp\u003e一旦第 $i$ 只鱼攻击了第 $j$ 只鱼,则会产出数量为 $value_i \\oplus value_j$ 的卵\u003c/p\u003e\n\u003cp\u003e每条鱼最多只能被攻击一次,也最多只能主动攻击一次\u003c/p\u003e\n\u003cp\u003e问产卵数量的最大可能总和\u003c/p\u003e\n\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n There is a kind of special fish in the East Lake where is closed to campus of Wuhan University. It’s hard to say which gender of those fish are, because every fish believes itself as a male, and it may attack one of some other fish who is believed to be female by it.\n \u003cbr\u003eA fish will spawn after it has been attacked. Each fish can attack one other fish and can only be attacked once. No matter a fish is attacked or not, it can still try to attack another fish which is believed to be female by it.\n \u003cbr\u003eThere is a value we assigned to each fish and the spawns that two fish spawned also have a value which can be calculated by XOR operator through the value of its parents.\n \u003cbr\u003eWe want to know the maximum possibility of the sum of the spawns.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The input consists of multiply test cases. The first line of each test case contains an integer n (0 \u0026lt; n \u0026lt;\u003d 100), which is the number of the fish. The next line consists of n integers, indicating the value (0 \u0026lt; value \u0026lt;\u003d 100) of each fish. The next n lines, each line contains n integers, represent a 01 matrix. The i-th fish believes the j-th fish is female if and only if the value in row i and column j if 1.\n\u003cbr\u003eThe last test case is followed by a zero, which means the end of the input."}},{"title":"Output","value":{"format":"HTML","content":"Output the value for each test in a single line."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e3\n1 2 3\n011\n101\n110\n0\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e6\u003c/pre\u003e"}}]}