"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 N 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.
The first line contains the number K (1≤K≤8) of the player holding the bomb when the game starts.
The second line contains the number of questions N (1≤N≤100).
Each of the next N lines contains the time T (in seconds, 1≤T≤100) spent answering the i-th question and that player's answer Z, separated by a space. Z is one of T, N, and P.
Print the number of the player who set off the bomb.