#include using namespace std; typedef long long ll; int main() { int n,m; cin>>n>>m; int cnt[n] {}; int drawn[n] {}; int turn = 0; int dir = 1; bool drawtwo = false; bool drawfour = false; for (int i = 0; i < m; i++) { string s; cin >> s; if (drawtwo) { if (s == "drawtwo") { cnt[turn]++; turn = (turn + dir + n) % n; continue; } else { drawn[turn] += 2; turn = (turn + dir + n) % n; drawtwo = false; } } else if (drawfour) { if (s == "drawfour") { cnt[turn]++; turn = (turn + dir + n) % n; continue; } else { drawn[turn] += 4; turn = (turn + dir + n) % n; drawfour = false; } } cnt[turn]++; if (s == "drawtwo") drawtwo = true; else if (s == "drawfour") drawfour = true; else if (s == "reverse") dir = -dir; else if (s == "skip") turn = (turn + dir + n) % n; turn = (turn + dir + n) % n; } int winner = (turn - dir + n) % n; cout << winner + 1 << ' ' << cnt[winner] - drawn[winner] << endl; return 0; }