import sys readline = sys.stdin.readline draw = {"drawtwo\n":2, "drawfour\n":4} def solve(): n, m = map(int, input().split()) fi = [0] * n se = [0] * n cnt = 1 draw_cnt = 0 no = 0 last = "" for _ in range(m): l = readline() if l != last and "draw" in last: se[no] += draw[last] * draw_cnt no = (no + cnt) % n draw_cnt = 0 if se[no] == 0: fi[no] += 1 else: se[no] -= 1 if "draw" in l: draw_cnt += 1 elif "skip\n" == l: no = (no + cnt) % n elif "reverse\n" == l: cnt *= -1 no = (no + cnt) % n last = l no = (no - cnt) % n print(no + 1, fi[no]) solve()