Time limit
2s
Memory limit
128 MB
There are N people. Choose six distinct people and arrange them in a circle for a game.
Because adjacent people must hold hands, every person in the circle must know both neighbors. The same six people can make different circles when their circular order changes. Rotations are considered the same circle, and the two opposite directions of the same order are also considered the same. For example, the order (1-2-3-4-5-6-1) is the same as (1-6-5-4-3-2-1), but it is different from (1-2-4-3-5-6-1).
Count how many different circles can be formed.
The first line contains the number of candidates N (6 <= N <= 150).
The next N lines give the acquaintance relation as an adjacency matrix. If A knows B, then B also knows A.
Print the number of possible circles modulo 9901.
For a complete graph with N = 6, the answer is 60. For a complete graph with N = 7, the answer is 420.