Delete 4 edges
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

Given two connected graphs G_1,G_2. You should count the number of ways to delete 4 edges from G_1\square G_2 such that G_1\square G_2 becomes disconnected, where G_1\square G_2 is the Cartesian product of G_1 and G_2 (See the next section for formal definitions).

In graph theory, the Cartesian product G \square H of graphs G and H is a graph such that:
  • the vertex set of G \square H is the Cartesian product V(G) \times V(H); and
  • two vertices (u,v) and (u',v') are adjacent in G \square H if and only if either
    • u = u' and v is adjacent to v' in H, or
    • v = v' and u is adjacent to u' in G.

Since the answer might be large, you should output the answer modulo 998\,244\,353.

输入描述:

The input consists of descriptions of the two graphs G_1 and G_2 sequentially. 

For each graph, the first line contains two integers n,m (5\leq n\leq 2\cdot 10^5, n-1\leq m\leq 2\cdot 10^5), denoting the number of vertices and edges in the graph, followed by m lines, with each line containing two integers u,v (1\leq u,v\leq n), denoting an edge in the graph.

It is guaranteed that both graphs are connected, and have no self-loop or multiple edges.

输出描述:

Output an integer in a line, denoting the number of ways to delete 4 edges to disconnect the graph G_1\square G_2, taken modulo 998\,244\,353.
示例1

输入

复制
5 5
1 2
2 3
3 4
4 5
5 1
6 6
1 2
2 3
3 4
4 5
5 6
6 1

输出

复制
30
示例2

输入

复制
6 5
1 2
1 3
1 4
2 5
2 6
5 5
1 2
2 3
3 4
4 1
3 5

输出

复制
6154

备注: