Statement : E3. Graph Cutting (Three Vertices, Any Size)
Triplet warmup — same idea as E0, but three pinned vertices. Count connected subgraphs that contain all of $a$, $b$, and $c$. Next steps: E4 (fixed size), then E (all triples, minimal cut).
You are given a tree with $n$ vertices and three distinct vertices $a$, $b$, $c$. Count connected vertex sets $S$ with $\{a,b,c\}\subseteq S$.
The first line contains an integer $t$ ($1 \le t \le 500$).
Each test case:
- One line: $n$, $a$, $b$, $c$ ($3 \le n \le 2000$, $1 \le a,b,c \le n$, pairwise distinct).
- Then $n - 1$ lines: tree edges.
It is guaranteed that the sum of $n$ over all test cases does not exceed $2000$.
For each test case, print the number of connected subgraphs containing $a$, $b$, and $c$, modulo $998244353$.
Input
3
4 1 2 3
1 2
3 1
4 1
4 1 2 4
1 2
3 1
4 1
4 2 3 4
1 2
3 1
4 1
Output
2
2
1
Note
- $(a,b,c)=(1,2,3)$ on the star: the minimal core is $\{1,2,3\}$; leaf $4$ may or may not be added → $2$ subgraphs.
- $(1,2,4)$: same structure, optional leaf $3$ → $2$.
- $(2,3,4)$: the three leaves force center $1$; the only connected superset is the whole tree → $1$.