#include using namespace std; #define inc(i, n) for(int i = 0; i < (n); i++) int n, m, x[100000]; string s[300001]; int main() { cin >> n >> m; inc(i, m) { cin >> s[i]; } string t; inc(i, m) { if(s[i] == "number" ) { t += "x"; } if(s[i] == "skip" ) { t += "x-"; } if(s[i] == "reverse" ) { t += "r"; } if(s[i] == "drawtwo" ) { t += "2"; if(s[i + 1] != s[i]) { t += "-"; } } if(s[i] == "drawfour") { t += "4"; if(s[i + 1] != s[i]) { t += "-"; } } } if(t.back() == '-') { t.pop_back(); } int p = -1, d = +1, c = 0; inc(i, t.size()) { p = (p + d + n) % n; if(t[i] == '-') { x[p] -= c; c = 0; } else { x[p]++; if(t[i] == 'r') { d *= -1; } if(t[i] == '2') { c += 2; } if(t[i] == '4') { c += 4; } } } cout << p + 1 << " " << x[p] << endl; return 0; }