#include #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() #define pb push_back #define fs first #define sc second #define show(x) cout << #x << " = " << (x) << endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) using namespace std; template ostream& operator<<(ostream& o,const pair &p){ return o<<"("< ostream& operator<<(ostream& o,const vector &vc){ o<<"{"; for(const T& v:vc) o< using V = vector; template using VV = vector>; int main(){ int N,M; cin>>N>>M; V a(N); int x = 0; int d = 1; string prev; int px = -1; int ren = 0; rep(i,M){ px = x; string s; cin>>s; a[x]--; if(s == "number"){ x = (x+d+N)%N; ren = 0; } if(s == "skip"){ x = (x+d+d+N)%N; ren = 0; } if(s == "reverse"){ d = -d; x = (x+d+N)%N; ren = 0; } if(s == "drawtwo"){ if(prev == "drawtwo"){ a[x]++; x = (x-d+N)%N; px = x; a[x]--; a[x] -= 2*ren; ren++; }else{ ren = 1; } a[(x+d+N)%N] += 2*ren; x = (x+d+d+N)%N; } if(s == "drawfour"){ if(prev == "drawfour"){ a[x]++; x = (x-d+N)%N; px = x; a[x]--; a[x] -= 4*ren; ren++; }else{ ren = 1; } a[(x+d+N)%N] += 4*ren; x = (x+d+d+N)%N; } prev = s; } cout<