def next_id(): global id if reverse: id = N - 1 if id == 0 else id - 1 else: id = (id + 1) % N def Drawtwo(): global drawtwo if drawtwo != 0: D[id] += drawtwo drawtwo = 0 next_id() def Drawfour(): global drawfour if drawfour != 0: D[id] += drawfour drawfour = 0 next_id() N, M = map(int, input().split()) C, D = [0] * N, [0] * N id = 0 reverse = False skip = False drawtwo = 0 drawfour = 0 for i in range(M): L = input() if L == "number": Drawtwo() Drawfour() C[id] += 1 elif L == "drawtwo": Drawfour() C[id] += 1 drawtwo += 2 elif L == "drawfour": Drawtwo() C[id] += 1 drawfour += 4 elif L == "skip": Drawtwo() Drawfour() C[id] += 1 skip = True elif L == "reverse": Drawtwo() Drawfour() C[id] += 1 reverse = True if not reverse else False #print(C, D) if i == M - 1: print(id + 1, C[id] - D[id]) break next_id() if skip: next_id() skip = False