#include using namespace std; typedef long long ll; #define REP(i,n) for(int i=0; i #define VLL vector #define VVI vector> #define VVLL vector> #define VC vector #define VS vector #define VVC vector> #define fore(i,a) for(auto &i:a) typedef pair P; template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 2147483647; const ll INFL = 9223372036854775807; const ll mod = 1000000007; int main() { int n, m; cin >> n >> m; int dt = 0, df = 0; bool b = true; VI v(n, 0); int tmp = 0; REP(i, m) { string s; cin >> s; if (s == "number") { if (dt + df == 0) { v[tmp]++; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; } else { v[tmp] -= dt + df; dt = 0; df = 0; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; v[tmp]++; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; } } else if (s == "drawtwo") { if (dt) { dt += 2; v[tmp]++; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; } else if (df) { v[tmp] -= df; df = 0; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; v[tmp]++; dt = 2; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; } else { v[tmp]++; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; dt = 2; } } else if (s == "drawfour") { if (df) { df += 2; v[tmp]++; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; } else if (dt) { v[tmp] -= dt; dt = 0; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; v[tmp]++; df = 4; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; } else { v[tmp]++; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; df = 4; } } else if (s == "skip") { if (dt + df == 0) { v[tmp]++; if (b)tmp = (tmp + 2) % n; else tmp = (tmp - 2 + n) % n; } else { v[tmp] -= dt + df; dt = 0; df = 0; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; v[tmp]++; if (b)tmp = (tmp + 2) % n; else tmp = (tmp - 2 + n) % n; } } else { if (dt + df == 0) { v[tmp]++; if (b)b = false; else b = true; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; } else { v[tmp] -= dt + df; dt = 0; df = 0; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; v[tmp]++; if (b)b = false; else b = true; if (b)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; } } } if (b == false)tmp = (tmp + 1) % n; else tmp = (tmp - 1 + n) % n; cout << tmp + 1 << ' ' << v[tmp] << endl; }