시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
12 초 512 MB 1 1 1 100.000%

문제

Bobo gets a bipartite graph with $n$ 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 \times 2 = 4$ different values associated to a given edge.

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

입력

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

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

Each of the following $m$ lines contains $6$ integers $a_i, b_i, v_{i, 00}, v_{i, 01}, v_{i, 10}, v_{i, 11}$, which denotes an edge between vertices $a_i$ and $b_i$ ($1 \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_i$ and $b_i$ are both white, the $i$-th edge's value is $v_{i, 00}$.
  • If vertex $a_i$ is white and $b_i$ is black, the value is $v_{i, 01}$.
  • If vertex $a_i$ is black and $b_i$ is white, the value is $v_{i, 10}$.
  • If vertices $a_i$ and $b_i$ are both black, the value is $v_{i, 11}$.

출력

A single integer denotes the sum.

예제 입력 1

2 1
1 2 1 2 3 4

예제 출력 1

10

예제 입력 2

3 2
1 2 1 0 0 1
2 3 1 0 0 1

예제 출력 2

2