N, M = map(int, input().split()) now = 0 dr = 1 L = [0] * N cnt2, cnt4 = 0, 0 for i in range(M): c = input() if cnt2: if c == "drawtwo": L[now] += 1 cnt2 += 2 now += dr now %= N continue else: L[now] -= cnt2 cnt2 = 0 now += dr now %= N if cnt4: if c == "drawfour": L[now] += 1 cnt4 += 4 now += dr now %= N continue else: L[now] -= cnt4 cnt4 = 0 now += dr now %= N L[now] += 1 if c == "number": pass elif c == "drawtwo": cnt2 += 2 elif c == "drawfour": cnt4 += 4 elif c == "skip": now += dr now %= N else: dr *= -1 now += dr now %= N if now == 0: now = 1 print(now, L[now - 1])