Given a tree, you can maintain a set that supports three types of operations:
- Insert a node $x$ into the current set.
- Undo the last insertion operation.
- Mark the current set of nodes as the subtree complement information for the $i$-th node.
The subtree complement information of a node $x$ is defined as the set of nodes obtained by removing all nodes in the subtree of $x$ (including $x$ itself) from the set of all nodes in the tree. You must ensure that the subtree complement information for every node is correct.
Input
This problem contains multiple test cases.
Each test case is formatted as follows:
The first line contains a positive integer $n$.
The next line contains $n-1$ positive integers, where the $i$-th number represents the parent $j$ of node $i+1$. It is guaranteed that $j < i+1$.
Read until EOF.
Output
For each test case, output a string. From left to right, each substring in the form "+x" represents performing operation 1 on node $x$, each "-" substring represents performing operation 2, each "=x" substring represents performing operation 3 on node $x$, and each "!" substring represents that all operations are finished; any input following it will be ignored. The string must end with "!".
The output string must not contain any whitespace characters.
Examples
Input 1
6
1 1 2 3 3
6
1 1 2 3 3
Output 1
=1+1+3+5+6=2+2=4----+4+2=3+3+6=5-+5=6!
=1+1+3+5+6=2+2=4----+4+2=3+3+6=5-+5=6!
Subtasks
Idea: nzhtl1477, Solution: ccz181078, Code: ccz181078, Data: ccz181078 & nzhtl1477
For $100\%$ of the data, $1 \le n \le 10^5$ and $1 \le T \le 3$.
The number of allowed type 1 operations is $4.5 \times 10^6$. It is not allowed to insert an element that is already present in the current set.
When there is no last un-undone insertion operation, type 2 operations are not allowed.
For each node, you must perform exactly one type 3 operation.