import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,M = map(int,readline().split()) LOG = read().decode() LOG = LOG.replace('number','n') LOG = LOG.replace('skip','s') LOG = LOG.replace('drawtwo','2') LOG = LOG.replace('drawfour','4') LOG = LOG.replace('reverse', 'r') LOG = LOG.split() num = [0] * N player = -1 dx = 1 draw_2 = 0 draw_4 = 0 for L in LOG: player += dx player %= N if draw_2 and L != '2': num[player] += 2 * draw_2 draw_2 = 0 player += dx if draw_4 and L != '4': num[player] += 4 * draw_4 draw_4 = 0 player += dx player %= N num[player] -= 1 if L == 's': player += dx elif L == 'n': pass elif L == 'r': dx *= -1 elif L == '2': draw_2 += 1 elif L == '4': draw_4 += 1 x = -num[player] print(player+1, x)