#AGC052F. [AGC052F] Tree Vertices XOR

[AGC052F] Tree Vertices XOR

Score : 20002000 points

Problem Statement

You are given a tree with NN vertices. The vertices are numbered from 11 to NN, and the ii-th edge connects vertices uiu_i and viv_i.

Initially, on each vertex of the tree is written number 11.

In one operation, you can do the following:

  • Choose any vertex vv of the tree. Let XX be the XOR of the values written in the neighbors of vv. Then, if the number written on vv is ava_v, replace it by (av XOR X)(a_v\ \mathrm{XOR}\ X).

You can perform this operation any finite (maybe zero) number of times. How many configurations can you achieve? As this number can be large, output it modulo 998244353998244353.

Two configurations are called different if there exists a vertex vv, such that the numbers written in vv in these configurations are different.

Constraints

  • 3N21053 \le N \le 2\cdot 10^5
  • 1ui,viN1\le u_i, v_i \le N
  • uiviu_i \neq v_i
  • The input represents a valid tree.

Input

Input is given from Standard Input in the following format:

NN

u1u_1 v1v_1

u2u_2 v2v_2

\vdots

uN1u_{N-1} vN1v_{N-1}

Output

Output the number of configurations you can get from the initial state, modulo 998244353998244353.

4
1 2
2 3
3 4
10

We can get the following configurations (abcdabcd means vertices 1,2,3,41,2,3,4 have a,b,c,da,b,c,d written on them): 11111111, 11101110, 11001100, 10001000, 01110111, 01100110, 01000100, 00110011, 00100010, 00010001.

5
1 2
1 3
1 4
1 5
24
6
1 3
2 3
3 4
4 5
4 6
40
9
1 2
2 3
1 4
4 5
1 6
6 7
7 8
8 9
255