def main(): n,m =map(int,input().split()) players =[0]*n cur =-1 rev =0 d2,d4=0,0 def nex(cur): cur += [1,-1][rev] if cur<0: cur = n + cur else: cur %=n return cur for _ in range(m): cur = nex(cur) cmd=input() if d2: if cmd == 'drawtwo': d2+=1 players[cur] +=1 continue else: players[cur] -=2*d2 d2 =0 cur = nex(cur) elif d4: if cmd == 'drawfour': d4+=1 players[cur] +=1 continue else: players[cur] -=4*d4 d4 =0 cur = nex(cur) players[cur] +=1 if cmd == 'number': pass elif cmd =='skip': cur=nex(cur) elif cmd =='reverse': rev +=1 rev %=2 elif cmd == 'drawtwo': d2 =1 elif cmd == 'drawfour': d4 =1 print('{} {}'.format(cur+1,players[cur])) main()