#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin >> N >> M; vector card(M); rep(i,M) cin >> card[i]; int id = 0, sgn = +1; vector ids = {}, cnt(N, 0); rep(p,M) { ids.push_back(id); if(card[p] == "number") { cnt[id]++; id = (id + sgn + N) % N; } else if(card[p] == "drawtwo") { cnt[id]++; int sum = 2; while(p + 1 < M && card[p + 1] == "drawtwo") { id = (id + sgn + N) % N; cnt[id]++; p++; sum += 2; } id = (id + sgn + N) % N; cnt[id] -= sum; id = (id + sgn + N) % N; } else if(card[p] == "drawfour") { cnt[id]++; int sum = 2; while(p + 1 < M && card[p + 1] == "drawfour") { id = (id + sgn + N) % N; cnt[id]++; p++; sum += 2; } id = (id + sgn + N) % N; cnt[id] -= sum; id = (id + sgn + N) % N; } else if(card[p] == "skip") { cnt[id]++; id = (id + sgn + sgn + N) % N; } else if(card[p] == "reverse") { cnt[id]++; sgn *= -1; id = (id + sgn + N) % N; } else { assert(0); } } cout << ids.back() + 1 << " " << cnt[ids.back()] << endl; }