Tram

No attempts yetTime limit1sMemory limit256 MB

Problem

To ease the traffic jams in Seoul, mayor Kim Sang-geun brought in a tram. The seats of the tram form a grid of NN rows and 2 columns. The rows are numbered 1 through NN, and the columns are numbered 1 and 2.

The distance between seats (RA,CA)(R_A, C_A) and (RB,CB)(R_B, C_B) is the distance between the centers of the two cells, (RARB)2+(CACB)2\sqrt{(R_A-R_B)^2+(C_A-C_B)^2}.

Most people sit as far away from the other passengers as they can. When a passenger steps into the tram, they measure for every empty seat the distance from that seat to the nearest seated passenger, and they take the seat where that distance is largest. When several seats tie, they take the one with the smaller row number, and when the row number ties as well, the one with the smaller column number. A passenger who has sat down stays in that seat until leaving the tram. A passenger who boards an empty tram sits in row 1, column 1.

You are given the log of passengers boarding and leaving. Write a program that reports the seat each passenger takes.

The log has MM lines, numbered 1 through MM in the order given. There are two kinds of lines. 'E' means a passenger boarded, and 'L' means a passenger left. A line that records a departure also tells on which line that passenger boarded.

A boarding line appears only when at least one seat is empty.

Input

The first line contains the number of rows NN and the number of log lines MM. (1N150,0001 \le N \le 150{,}000, 1M30,0001 \le M \le 30{,}000)

Each of the next MM lines records a boarding or a departure. When line KK is 'L', it comes with PKP_K (1PKK1 \le P_K \le K), meaning that the passenger who boarded on line PKP_K leaves. Line PKP_K is always 'E', and no passenger leaves twice.

Output

Every time an 'E' line is given, print on its own line the row number and the column number of the seat that passenger takes, separated by a single space.