n,m=gets.split.map &:to_i a=[0]*n k=x=0 d=1 prev='' (m-1).times{ # discard the final turn s=gets.chomp if prev!=s&&prev.start_with?('draw') a[k]+=x k=(k+d)%n x=0 end a[k]+=1 if s=='drawtwo' x+=2 elsif s=='drawfour' x+=4 elsif s=='skip' k=(k+d)%n elsif s=='reverse' d=-d end prev=s k=(k+d)%n } puts [k+1,a[k]+1]*' '