def get_next(N): def _(current,reverse): if current == None: return 0 if reverse: next = current - 1 if next < 0: next-=N else: next = current + 1 return next % N return _ N,M = map(int,input().split()) log = [input() for x in range(M)] players = [[0,0] for x in range(N)] g_next = get_next(N) current = None reverse = False d_two = 0 d_four = 0 skipper = -1 for card in log: current = g_next(current,reverse) if d_two: if card != "drawtwo": players[current][1]+=d_two*2 current = g_next(current,reverse) d_two = 0 elif d_four: if card != "drawfour": players[current][1]+=d_four*4 current = g_next(current,reverse) d_four = 0 players[current][0]+=1 if card == "drawtwo": d_two += 1 elif card == "drawfour": d_four += 1 elif card == "skip": skipper = current current = g_next(current,reverse) elif card == "reverse": reverse^=True if card == "skip": current = skipper print(current + 1,players[current][0] - players[current][1])