import java.util.Scanner; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; class A{ A() {} int put[], draw[]; int n, m, turn, dir; void proceed(){ turn = (turn+dir+n)%n; } void solve() throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line[] = br.readLine().split(" "); n = Integer.parseInt(line[0]); m = Integer.parseInt(line[1]); put = new int[n]; draw = new int[n]; int d2 = 0; int d4 = 0; turn = 0; dir = 1; String card; while(m-- > 0){ card = br.readLine(); if(d2 > 0 && card.equals("drawtwo")){ d2++; put[turn]++; proceed(); continue; } if(d4 > 0 && card.equals("drawfour")){ d4++; put[turn]++; proceed(); continue; } if(d2 > 0){ draw[turn] += 2*d2; d2 = 0; proceed(); } if(d4 > 0){ draw[turn] += 4*d4; d4 = 0; proceed(); } put[turn]++; if(card.equals("drawtwo")){ d2++; }else if(card.equals("drawfour")){ d4++; }else if(card.equals("skip")){ proceed(); }else if(card.equals("reverse")){ dir *= -1; }else if(card.equals("number")){ // do nothing. } proceed(); } turn = (turn-dir+n)%n; System.out.println((turn+1) + " " + (put[turn]-draw[turn])); } } class Main{ public static void main(String[] args) throws IOException{ new A().solve(); } }