Codeforces
CF Step
Youtube Linkedin Discord Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Statement : E4. Graph Cutting (Three Vertices, Fixed Size)

E4. Graph Cutting (Three Vertices, Fixed Size)

After E3. Same as E1, but the three pinned vertices $a$, $b$, $c$ define a Steiner tree core instead of a single path. Count connected subgraphs $S$ with $\{a,b,c\}\subseteq S$ and $|S|=d$.

The final step E counts all triples under Fedya’s minimal-cut rule.


Input

The first line contains an integer $t$ ($1 \le t \le 500$).

Each test case:

  • One line: $n$, $d$, $a$, $b$, $c$ ($3 \le d \le n \le 2000$, distinct $a,b,c$).
  • Then $n - 1$ lines: tree edges.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2000$.


Output

For each test case, print the number of connected subgraphs of size exactly $d$ that contain $a$, $b$, and $c$, modulo $998244353$.


Example

Input

4
4 3 1 2 3
1 2
3 1
4 1
4 4 1 2 3
1 2
3 1
4 1
4 3 1 2 3
1 2
3 1
4 1
4 4 2 3 4
1 2
3 1
4 1

Output

1
1
1
1

Note

  • $(1,2,3)$, $d=3$: only $\{1,2,3\}$.
  • $(1,2,3)$, $d=4$: only $\{1,2,3,4\}$.
  • $(1,2,3)$, $d=3$ again: still $1$.
  • $(2,3,4)$, $d=4$: Steiner core is the whole star (size $4$); no extras possible.

Compare with E on the same tree, $d=3$: valid triples for minimal cut are $(1,2,3)$, $(1,2,4)$, $(1,3,4)$ — three objects, not three subgraph counts.