n, m = map(int, input().split()) i = 0 t = 1 bef = "_" have = [0] * n cnt = 0 for j in range(m): l = input() if l != bef and bef[0] == "d": if bef[4] == "t": have[i] -= 2 * cnt else: have[i] -= 4 * cnt cnt = 0 i += t i %= n have[i] += 1 if j == m - 1: break if l[0] == "s": i += 2 * t elif l[0] == "r": t *= -1 i += t elif l[0] == "d": i += t cnt += 1 else: i += t i %= n bef = l print(i + 1, have[i])