n, m = map(int, input().split()) i = 0 t = 1 bef = "_" have = [0] * n cnt = 0 for _ in range(m - 1): 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 else: have[i] += 1 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] + 1)