Random tree
Consider the following process of building a tree T.
Initially, the tree consists of one vertex, which has the number 1.
Further vertices with numbers 2 ... n are added to the tree.
At the i-th step, a vertex with number i + 1 is added to the tree, and an edge from it to some already added vertex p (1 ≤ p ≤ i), which is chosen among them randomly with equal probability.
Let V be the set of vertices already added to T.
Then let f(A) be the number of vertices T that lie either in A or on the path between any two vertices from A (perhaps both there and there).
After adding each vertex, your task is to print the sum f(A) over all sets A, which are subsets of the set of vertices already added to T (Σ f( A) over all A ⊂ V). Since the answers can be very large, print only the remainder of the answer divided by 998244353.
Input
The first line contains a single number n (2 ≤ n ≤ 200000) - the number of vertices in the tree after the last step.
The next line contains n - 1 integer p[1]
, p[2]
, ..., p[n]
(1 ≤ p [i]
≤ i), denoting adding to the graph the vertex i + 1 and the edge between p[i]
and i + 1, respectively . It is guaranteed that p[i]
is chosen randomly with equal probability among the numbers from 1 to i.
Output
Print n - 1 integer - the remainders from division (Σ f(A) over all A ⊂ V) by **998244353 ** after adding each vertex.