LaLa and Monster Hunting (Part 2)
시간 제한6초메모리 제한1024 MB
주어진 그래프에서 고정된 6개 정점 패턴 그래프와 동형인 부분 그래프의 개수를 998244353으로 나눈 나머지로 구한다.
문제
A dreadful monster has been witnessed in a forest near the city of Sharia, and a group of valorous adventurers will hunt it down in few days before it hurt anyone. However, knows that the real reason those adventurers are willing to take the risk is to obtain the rare stone that the monster is known to produce in its intestines. would like to obtain the stone before they do, as it is known to be quite beautiful.
Currently, knows a rough estimate of the location of the monster. However, the monster excels at camouflage, so it's really hard to hunt it down when it's hiding in the network of branches.
For the sake of simplicity, we'll model the monster as a graph with vertices described below:

The network of branches can be modeled as a simple graph . A candidate is a subgraph of that is isomorphic to . In other words, it is a graph obtained by deleting some edges from , and then deleting some vertices that none of the remaining edges are incident to, whose vertices can be renumbered so that it coincides with . will now have to examine all possible candidates to search and hunt the monster down.
Write a program that computes the number of candidates will have to examine, modulo .
입력
The input describes the branch network and is given in the following format:
where is the number of joints, numbered from to and is the number of branches, -th of which connects the joints and .
The input satisfies the following constraints:
- All the numbers in the input are integers.
- for all integers
- or for all integers
Note that the network is not necessarily connected.
출력
The output should be a single integer equal to the number of candidates, modulo .
힌트
The followings illustrate the candidates (the regular edges) of the branch network in the first sample test.



