import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long M = sc.nextLong(); sc.nextLine(); // 酔っ払いたちの生成 Yopparai yop[] = new Yopparai[N]; for (int i = 0; i < N; i++) { yop[i] = new Yopparai(i + 1); } // UNOシステム boolean reverse = false; boolean skip = false; int order = 0; long drawtwoCount = 0; long drawforCount = 0; for (long i = 0; i < M; i++) { String card = sc.nextLine(); if (drawtwoCount > 0 && !card.equals("drawtwo")) { yop[order].math -= drawtwoCount * 2; drawtwoCount = 0; order = nextOrder(N, reverse, order, skip); } if (drawforCount > 0 && !card.equals("drawfour")) { yop[order].math -= drawforCount * 4; drawforCount = 0; order = nextOrder(N, reverse, order, skip); } switch (card) { case "number" : break; case "drawtwo" : drawtwoCount++; break; case "drawfour" : drawforCount++; break; case "skip" : skip = true; break; case "reverse" : reverse = !reverse; break; } yop[order].math++; if (i != M - 1) order = nextOrder(N, reverse, order, skip); skip = false; } System.out.printf("%d %d", yop[order].id, yop[order].math); } // 次の酔っ払いの手番を求める public static int nextOrder(int N, boolean reverse, int order, boolean skip) { int tmp = 0; if (reverse) { tmp = order - 1; tmp = tmp < 0 ? N - 1 : order - 1; if (skip) tmp = tmp - 1 < 0 ? N - 1 : tmp - 1; } else { tmp = order + 1; tmp = tmp > N - 1 ? 0 : order + 1; if (skip) tmp = tmp + 1 > N - 1 ? 0 : tmp + 1; } return tmp; } } class Yopparai { public int id; public long math; public Yopparai (int a) { id = a; math = 0; } }