Walk of Length 6

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Bobo has an undirected graph with nn vertices which are conveniently labeled with 1,2,,n1, 2, \dots, n. Let VV be the set of vertices and EE be the set of edges. He would like to count the number of tuples (v_1,v_2,,v_6)(v\_1, v\_2, \dots, v\_6) where:

  • v_1,v_2,,v_6Vv\_1, v\_2, \dots, v\_6 \in V,
  • v_1,v_2,v_2,v_3,,v_5,v_6,v_6,v_1E\\{v\_1, v\_2\\}, \\{v\_2, v\_3\\}, \dots, \\{v\_5, v\_6\\}, \\{v\_6, v\_1\\} \in E;
  • C=(v_1,v_2,v_2,v_3,,v_5,v_6,v_6,v_1)\mathcal{C} = (\\{v\_1, v\_2\\}, \\{v\_2, v\_3\\}, \dots, \\{v\_5, v\_6\\}, \\{v\_6, v\_1\\}) is not a simple cycle of length 66.

입력

The input contains zero or more test cases, and is terminated by end-of-file. For each test case:

The first line contains an integer nn (1n10001 \leq n \leq 1000). 

The ii-th of the following nn lines contains a string g_ig\_i of length nn where g_i,jg\_{i, j} denotes the existence of edge i,j\\{i, j\\} (g_i,j0,1g\_{i, j} \in \\{0, 1\\}, g_i,i=0g\_{i, i} = 0, g_i,j=g_j,ig\_{i, j} = g\_{j, i}). 

It is guaranteed that the sum of nn does not exceed 10001000.

출력

For each test case, output an integer which denotes the number of tuples.