N, M = [int(_) for _ in input().split()] l = [input() for _ in range(M)] hands = [0] * N turn = 0 acc2 = 0 acc4 = 0 direction = +1 def next_player(): global turn turn = (turn + direction * distance) % N for i, li in enumerate(l): distance = 1 if acc2 > 0 and li != "drawtwo": hands[turn] += acc2 acc2 = 0 next_player() if acc4 > 0 and li != "drawfour": hands[turn] += acc4 acc4 = 0 next_player() if li == "drawtwo": acc2 += 2 if li == "drawfour": acc4 += 4 if li == "number": pass if li == "skip": distance = 2 if li == "reverse": direction *= -1 hands[turn] -= 1 if i == M - 1: print(turn + 1, -hands[turn]) else: next_player()