Number of Colorful Matchings

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

문제

You are given a graph GG with nn black nodes and nn white nodes, where every edge can only connect a black node and a white node (in other words, the graph is bipartite).

Each edge in GG has a color: either blue or red. No two edges of the same color can connect the same pair of vertices (in other words, there are no same-color parallel edges).

For every kk from 00 to nn, please count the number of perfect matchings in GG that contain exactly kk red edges and nkn - k blue edges. Recall that a perfect matching is a subset of nn edges in which no two edges can share a common endpoint. Since the number could be large, you are only required to output the answers modulo 22.

입력

The first line contains a non-negative integer nn (1n3001 \le n \le 300).

Each of the next nn lines contains nn characters with no spaces. Together, these lines describe the adjacency matrix of red edges. The jj-th character on the ii-th line is "1" if there is one red edge connecting the ii-th black node and the jj-th white node, and "0" otherwise.

The next nn lines describe the adjacency matrix of blue edges, in the same format as above.

출력

Output n+1n + 1 lines containing your answers for k=0,1,2,,nk = 0, 1, 2, \ldots, n respectively. Remember that you only need to output the answer modulo 22.

힌트

In the example, there exist three perfect matchings:

  1. red (1,1)(1, 1), blue (2,2)(2, 2)
  2. red (1,2)(1, 2), blue (2,1)(2, 1)
  3. red (1,2)(1, 2), red (2,1)(2, 1)