Adjustment Office#7561

Adjustment Office

1 секунда
128 мегабајти
Многу лесно

Garrison and Anderson are working in a company named "Adjustment Office". In competing companies workers change the reality, in this company they try to predict the future.

They are given a big square board n \times n. Initially in each cell of this board the value of x + y~(1 \le x, y \le n) is written. They know that in the future there will be two types of queries on the board:

They have predicted what queries and results there will be. They need to ensure that they have correctly predicted the results. Help them by computing the results of the queries.

Влез

The first line contains two integers and q~(1 \le n \le 10^6, 1 \le q \le 10^5) — the size of the square and the number of queries.

Each of the next lines contains the description of the query. Each query is either "R~r"~(1 \le r \le n) or "C~c"~(1 \le c \le n).

Излез

Print lines. The -th line shall contain one integer — the result of the -th query.

Примери

Пример 1

Loading
Loading