import java.io.*; import java.util.Scanner; public class Main_yukicoder769 { private static Scanner sc; private static Printer pr; private static void solve() { int n = sc.nextInt(); int m = sc.nextInt(); int[] num = new int[n]; int win = 0; int d = 1; int dup = 0; String prev = ""; for (int i = 0; i < m; i++) { String l = sc.next(); if (prev.equals("drawtwo") && !l.equals(prev)) { num[win] += 2 * dup; dup = 0; win += d; } else if (prev.equals("drawfour") && !l.equals(prev)) { num[win] += 4 * dup; dup = 0; win += d; } win = (win + n) % n; switch (l) { case "number": num[win]--; win += d; break; case "drawtwo": num[win]--; dup++; win += d; break; case "drawfour": num[win]--; dup++; win += d; break; case "skip": num[win]--; win += 2 * d; break; case "reverse": num[win]--; d = -d; win += d; break; } win = (win + n) % n; prev = l; } win -= d; win = (win + n) % n; pr.printf("%d %d%n", win + 1, -num[win]); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }