#arc130d. [arc130_d]Zigzag Tree

[arc130_d]Zigzag Tree

Problem Statement

Given is a tree with NN vertices. The vertices are numbered 11 to NN, and the ii-th edge connects Vertices aia_i and bib_i.

Find the number of sequences of positive integers P=(P1,P2,ldots,PN)P = (P_1, P_2, \\ldots, P_N) that satisfy the conditions below, modulo 998244353998244353.

  • 1leqPileqN1\\leq P_i\\leq N
  • PineqPjP_i\\neq P_j if ineqji\\neq j.
  • For 1leqa,b,cleqN1\\leq a, b, c\\leq N, if Vertices aa and bb are adjacent, and Vertices bb and cc are also adjacent, Pa<Pb>PcP_a < P_b > P_c or Pa>Pb<PcP_a > P_b < P_c holds.

Constraints

  • 2leqNleq30002\\leq N\\leq 3000
  • 1leqai,bileqN1\\leq a_i, b_i\\leq N
  • The given graph is a tree.

Input

Input is given from Standard Input in the following format:

NN a1a_1 b1b_1 a2a_2 b2b_2 vdots\\vdots aN1a_{N-1} bN1b_{N-1}

Output

Print the answers.


Sample Input 1

3
1 2
2 3

Sample Output 1

4

The 44 sequences satisfying the conditions are:

  • P=(1,3,2)P = (1, 3, 2)
  • P=(2,1,3)P = (2, 1, 3)
  • P=(2,3,1)P = (2, 3, 1)
  • P=(3,1,2)P = (3, 1, 2)

Sample Input 2

4
1 2
1 3
1 4

Sample Output 2

12

Sample Input 3

6
1 2
2 3
3 4
4 5
5 6

Sample Output 3

122

Sample Input 4

9
8 5
9 8
1 9
2 5
6 1
7 6
3 8
4 1

Sample Output 4

19080