N,M = map(int, input().split()) ans = 0 prev = 0 next = 1 card = [0]*N cnt = 0 for _ in range(M): l = input() card[ans] += 1 if (prev == "drawtwo" or prev == "drawfour") and prev != l: card[ans] -= 1+cnt cnt = 0 ans += next card[ans%N] += 1 if l == "number" or l == "drawtwo" or l == "drawfour": ans += next if l == "drawtwo": cnt += 2 elif l == "drawfour": cnt += 4 elif l == "skip": ans += next*2 elif l == "reverse": next *= -1 ans += next prev = l ans %= N ans = (ans-next)%N+1 print(ans, card[ans-1])