import java.util.Scanner; class A{ A() {} int put[], draw[]; int n, m, turn, dir; void proceed(){ turn = (turn+dir+n)%n; } void solve(){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); m = sc.nextInt(); put = new int[n]; draw = new int[n]; int d2 = 0; int d4 = 0; turn = 0; dir = 1; String card; while(m-- > 0){ card = sc.next(); 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){ new A().solve(); } }