# coding: utf-8 # Your code here! input_params = list(map(int,input().split())) n = input_params[0] m = input_params[1] card = [input() for i in range(m)] count = [0] * n def get_next_turn(turn, direction): if direction == 1: if turn == n: return 1 else: return turn + 1 else: if turn == 1: return n else: return turn -1 turn = 1 direction = 1 res = -1 d2_continue = 0 d4_continue = 0 for i in range(len(card)): if i == len(card)-1: res = turn count[turn-1] += 1 break count[turn-1] += 1 if card[i] == 'number': turn = get_next_turn(turn, direction) elif card[i] == 'drawtwo': d2_continue += 1 if card[i+1] == 'drawtwo': turn = get_next_turn(turn, direction) else: turn = get_next_turn(turn, direction) count[turn-1] += -2 * d2_continue d2_continue= 0 turn = get_next_turn(turn, direction) elif card[i] == 'drawfour': d4_continue += 1 if card[i+1] == 'drawfour': turn = get_next_turn(turn, direction) else: turn = get_next_turn(turn, direction) count[turn-1] += -4 * d4_continue d4_continue= 0 turn = get_next_turn(turn, direction) elif card[i] == 'skip': turn = get_next_turn(turn, direction) turn = get_next_turn(turn, direction) elif card[i] == 'reverse': direction *= -1 turn = get_next_turn(turn, direction) print('{} {}'.format(res, count[res-1]))