Score : 900 points
Problem Statement
Given are simple undirected graphs X, Y, Z, with N vertices each and M1, M2, M3 edges, respectively.
The vertices in X, Y, Z are respectively called x1,x2,…,xN, y1,y2,…,yN, z1,z2,…,zN.
The edges in X, Y, Z are respectively (xai,xbi), (yci,ydi), (zei,zfi).
Based on X, Y, Z, we will build another undirected graph W with N3 vertices.
There are N3 ways to choose a vertex from each of the graphs X, Y, Z. Each of these choices corresponds to the vertices in W one-to-one. Let (xi,yj,zk) denote the vertex in W corresponding to the choice of xi,yj,zk.
We will span edges in W as follows:
- For each edge (xu,xv) in X and each w,l, span an edge between (xu,yw,zl) and (xv,yw,zl).
- For each edge (yu,yv) in Y and each w,l, span an edge between (xw,yu,zl) and (xw,yv,zl).
- For each edge (zu,zv) in Z and each w,l, span an edge between (xw,yl,zu) and (xw,yl,zv).
Then, let the weight of the vertex (xi,yj,zk) in W be $1,000,000,000,000,000,000^{(i +j + k)} = 10^{18(i + j + k)}$. Find the maximum possible total weight of the vertices in an independent set
in W, and print that total weight modulo 998,244,353.
Constraints
- 2≤N≤100,000
- 1≤M1,M2,M3≤100,000
- 1≤ai,bi,ci,di,ei,fi≤N
- X, Y, and Z are simple, that is, they have no self-loops and no multiple edges.
Input is given from Standard Input in the following format:
N
M1
a1 b1
a2 b2
⋮
aM1 bM1
M2
c1 d1
c2 d2
⋮
cM2 dM2
M3
e1 f1
e2 f2
⋮
eM3 fM3
Output
Print the maximum possible total weight of an independent set in W, modulo 998,244,353.
2
1
1 2
1
1 2
1
1 2
46494701
The maximum possible total weight of an independent set is that of the set (x2,y1,z1), (x1,y2,z1), (x1,y1,z2), (x2,y2,z2). The output should be (3×1072+10108) modulo 998,244,353, which is 46,494,701.
3
3
1 3
1 2
3 2
2
2 1
2 3
1
2 1
883188316
100000
1
1 2
1
99999 100000
1
1 100000
318525248