Bipartite Graph Coloring

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

문제

Bobo gets a bipartite graph with nn vertices (that is, a graph without odd cycles).

He colors each vertex into black or white, and then calculates the product of each edge's value. The value of an edge is determined by the colors of its two end points. Thus, there can be 2×2=42 \times 2 = 4 different values associated to a given edge.

Now bobo would like to know the sum of products of all 2n2^n possible coloring, modulo (109+7)(10^9+7).

입력

The first line contains 22 integers n,mn, m which denotes the number of vertices and edges (2n402 \leq n \leq 40, 1m1001 \leq m \leq 100).

Vertices are numbered by 1,2,,n1, 2, \dots, n for convenience.

Each of the following mm lines contains 66 integers a_i,b_i,v_i,00,v_i,01,v_i,10,v_i,11a\_i, b\_i, v\_{i, 00}, v\_{i, 01}, v\_{i, 10}, v\_{i, 11}, which denotes an edge between vertices a_ia\_i and b_ib\_i (1a_i,b_in,0v_i,00,v_i,01,v_i,10,v_i,111091 \leq a\_i, b\_i \leq n, 0 \leq v\_{i, 00}, v\_{i, 01}, v\_{i, 10}, v\_{i, 11} \leq 10^9).

  • If vertices a_ia\_i and b_ib\_i are both white, the ii-th edge's value is v_i,00v\_{i, 00}.
  • If vertex a_ia\_i is white and b_ib\_i is black, the value is v_i,01v\_{i, 01}.
  • If vertex a_ia\_i is black and b_ib\_i is white, the value is v_i,10v\_{i, 10}.
  • If vertices a_ia\_i and b_ib\_i are both black, the value is v_i,11v\_{i, 11}.

출력

A single integer denotes the sum.