Rikka with Employees
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
Special Judge, 64bit IO Format: %lld

题目描述

Recently, Rikka became the boss of a big company. There are n employees in Rikka's company, indexed from 1 to n. Employee 1 is Rikka herself.
Each employee except Rikka has a direct supervisor. The direct supervisor of the i-th employee is the p_i-th employee. The supervision relationship constitutes a tree. Employee u is a subordinate of Employee v if and only if v is the direct supervisor or an indirect supervisor of u.
To encourage employees, Rikka decides to let each employee experience the feeling of being the boss. To achieve this, Rikka will give some employees a holiday. For an employee, he/she will feel like the boss only when the following three conditions are satisfied:
  • He/she is at work;
  • All his/her subordinates are at work;
  • All employees except he/she and his/her subordinates are on holiday.
Now, Rikka is going to make a plan. In the beginning, all employees are at work. In each day, Rikka can make one of the following actions:
  • Choose an index i and give the i-th employee a holiday. This action can be taken only when i is on work;
  • Recall an employee which is on holiday. If there are multiple employees which are on holiday, the employee with the shortest holiday will be back. Since the longer the holiday is, the farther the employee will be from the company, and thus the harder recalling he/she will be. Note that this action can be taken only when there is at least one on-holiday employee;
  • Choose an index i and interview him the feeling of being the boss. This action can be taken only when i is feeling like the boss at this time.
Rikka wants you to make a plan. Since it is expensive to give employees holidays, you are required to make every employee feel like the boss and interview them within days.

输入描述:

The first line contains a single integer , the number of employees.
The second line contains n-1 integers , representing the direct supervisor of each employee.

输出描述:

Output a single line with a single string. From left to right:
1. Substring "+x" represents to give the x-th employee a holiday;
2. Substring "-" represents to recall an employee;
3. Substring "=x" represents to interview the x-th employee.
Besides, Substring "!" represents that all actions are finished. Any characters after "!" will be ignored.
Your answer will be regarded as correct if and only if the following three conditions are satisfied:
1. The number of actions is no more than ;
2. All actions are valid;
3. For each , "=x" is invoked exactly once.
示例1

输入

复制
6
1 1 2 3 3

输出

复制
=1+1+3+5+6=2+2=4----+4+2=3+3+6=5-+5=6!