def main(): n,m = map(int,input().split()) players =[0]*n log =[] d2,d4=0,0 for i in range(m): c = input() if d2: if c !='drawtwo': d2 =0 log += ['pass2'] log += [c] continue if d4: if c !='drawfour': d4 =0 log += ['pass4'] log += [c] continue if c == 'drawtwo': d2 =1 elif c=='drawfour': d4=1 log += [c] #print(log) t = -1 r,d2,d4=0,0,0 def next_t(t,n,r): if r: t-=1 if t<0: t = n+t else: t +=1 t%=n return t for i in range(len(log)): t = next_t(t,n,r) c = log[i] #print('players:{} t:{} r:{} cmd:{}'.format(players,t,r,c)) players[t] +=1 if c =='drawfour': d4 +=1 elif c =='drawtwo': d2 +=1 elif c =='skip': t = next_t(t,n,r) elif c == 'reverse': r+=1 r%=2 elif c =='pass2': players[t] -=d2*2 d2 =0 elif c == 'pass4': players[t] -=d4*4 d4 =0 print('{} {}'.format(t+1,players[t])) main()