#include using namespace std; #define rep(i, N) for (int i = 0; i < (N); i++) #define all(a) (a).begin(), (a).end() #define pb push_back using ll = long long; using i_i = tuple; int main() { int N, M; cin >> N >> M; vector a(N); int i = 0, d = 1; int sum = 0, id; string prev; while (M--) { string s; cin >> s; if (sum > 0 && s != prev) { a[i] -= sum; sum = 0; i = (i + d + N) % N; } id = i; // cout << id << ' ' << s << endl; if (s == "number") { a[i]++; i = (i + d + N) % N; } if (s == "drawtwo") { a[i]++; sum += 2; i = (i + d + N) % N; } if (s == "drawfour") { a[i]++; sum += 4; i = (i + d + N) % N; } if (s == "skip") { a[i]++; i = (i + d + N) % N; i = (i + d + N) % N; } if (s == "reverse") { a[i]++; d *= -1; i = (i + d + N) % N; } prev = s; } cout << id + 1 << ' ' << a[id] << endl; }