Salaryman
Salaries in big tech are becoming increasingly competitive, so top FAANG company Famazon is rolling out a new payment structure.
Famazon's corporate hierarchy can be modeled as a complete binary tree with employees, numbered from
to
. Employee
is the CEO. For every employee
, their direct subordinates (if they exist) are employees
and
, provided these indices do not exceed
.
Initially, all employees have a salary of dollars. Whenever an employee receives a raise, their salary increases by some amount. Each employee directly under them receives a raise of one dollar less, their subordinates receive one dollar less than that, and so on. It is guaranteed that this number remains above
for all employees.
Throughout the year, events will occur at Famazon:
- Raise: A specified employee receives a raise, along with all employees under them as described above.
- Audit: The salary of a specified employee is audited and must be reported.
Help Famazon manage their company!
Input
The first line contains two integers and
(
,
), the number of employees at Famazon, and the number of queries. It is guaranteed that
for some positive integer
. The employees are numbered from
to
and form a complete binary tree, where:
- Employee
is the root.
- For every employee
, their left child (if it exists) is
and their right child is
.
- Employees with index greater than
do not exist.
The next lines will be in one of two forms:
PAYRISE A X, indicating that employeeshould get a raise of
dollars, the employees under them by one less, and so on. If
,
.
AUDIT A, indicating that you should output the pay of employee.
Output
Output the correct salaries for every AUDIT query.
Example
Input 1
7 6
PAYRISE 2 5
PAYRISE 1 2
AUDIT 2
AUDIT 1
PAYRISE 6 10
AUDIT 6
Output 1
6
2
10







Comments