| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 (추가 시간 없음) | 1024 MB (추가 메모리 없음) | 13 | 7 | 7 | 70.000% |
Yunee, the president of UNIST Rock-Paper-Scissors Association, held a rock-paper-scissors contest for UNIST students and gathered $N$ participants.
The contest consists of $M$ games in total. In each game, two or three participants make one of the three hand gestures—rock, paper, or scissors—all at once. Then the winner of each game is determined according to the following rules.
Each UNIST student had prepared one of the following strategies for this contest.
Unfortunately, Yunee couldn't watch the contest because of a lot of paperwork. But Yunee has a document that lists the participants and the winners of each game. Yunee wondered what strategies the students might have used. Find the number of possible strategy combinations of all students, modulo 10ドル^9+7$.
The first line contains two integers $N$ and $M$ $(3 \leq N \leq 300, 1 \leq M \leq 300)$. $N$ represents the number of participants of the contest. $M$ represents the number of games.
The next $M$ lines contain the descriptions for the $M$ games in chronological order. Each game is described as follows.
/ is given.Output the number of possible strategy combinations of all students, modulo 10ドル^9+7$.
3 3 2 1 2 / 1 1 2 2 3 / 1 2 3 1 2 3 / 0
27
In the first example, the following combination of strategies is possible, for instance.
The game proceeds as follows.
3 1 2 1 2 / 0
243
3 3 2 1 2 / 1 1 2 2 1 / 1 1 2 1 2 / 0
0