#include #define rep(i,a,b) for(int i=int(a);i> N >> M; vector V(N); int turn = 0, dir = 1, draw = 0; bool d2 = 0, d4 = 0; rep(i,0,M){ //cout << turn << " " << V[turn] << endl; string s; cin >> s; V[turn]++; onemore: if(draw){ if(d2 && s == "drawtwo" || d4 && s == "drawfour"){ draw += (s == "drawtwo" ? 2 : 4); }else{ d2 = d4 = 0; V[turn] -= draw; V[turn]--; draw = 0; turn = (turn + N + dir) % N; V[turn]++; goto onemore; } }else if(s == "drawtwo" || s == "drawfour"){ draw += (s == "drawtwo" ? 2 : 4); (s == "drawtwo" ? d2 : d4) = 1; }else if(s == "skip"){ turn += dir; }else if(s == "reverse"){ dir *= -1; } if(i == M-1){ cout << turn + 1 << " " << V[turn] << endl; break; } turn = (turn + N + dir) % N; /* cout << endl; rep(j,0,N){ cout << j << " " << V[j] << endl; } */ } }