I Love Croatia

No attempts yetTime limit1sMemory limit128 MB

Problem

"I love Croatia" is a Croatian television show made under a format license bought from the popular Dutch program "I love my country". The most popular game on the show is "Happy Birthday", and this problem is about that game.

Eight players sit in a circle in order from 1 to 8. The person immediately to the left of a player is the one whose number is larger by one, and the person immediately to the left of player 8 is player 1.

One of them holds a bomb. The bomb goes off 3 minutes and 30 seconds after the game starts. The game begins with a question to the player holding the bomb. A player who fails to answer correctly or skips the question keeps the bomb and receives the next question right away. A player who answers correctly hands the bomb to the player immediately on the left, and the player who receives it gets the next question.

You are given the number of the player holding the bomb when the game starts and the time spent answering each of the first NN questions. Write a program that finds the number of the player who set off the bomb.

For each question you are given the time that player took from hearing the question to answering it, and whether the answer was correct (T), wrong (N), or skipped (P). Speaking an answer, hearing a question, and handing over the bomb all count as 0 seconds. The input always makes the bomb go off while somebody is holding it.

Input

The first line contains the number KK (1K81 \le K \le 8) of the player holding the bomb when the game starts.

The second line contains the number of questions NN (1N1001 \le N \le 100).

Each of the next NN lines contains the time TT (in seconds, 1T1001 \le T \le 100) spent answering the ii-th question and that player's answer ZZ, separated by a space. ZZ is one of T, N, and P.

Output

Print the number of the player who set off the bomb.