/* -*- coding: utf-8 -*- * * 769.cc: No.769 UNOシミュレータ - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ enum { NUM, SKIP, REV, DRW2, DRW4 }; /* global variables */ char s[64]; int cns[MAX_N]; /* subroutines */ // "number", "drawtwo", "drawfour", "skip", "reverse" int readcard() { scanf("%s", s); if (s[0] == 'n') return NUM; if (s[0] == 's') return SKIP; if (s[0] == 'r') return REV; if (s[4] == 't') return DRW2; return DRW4; } inline int next_card(int cid, int t, int n) { return (cid + n + t) % n; } inline int prev_card(int cid, int t, int n) { return (cid + n - t) % n; } /* main */ int main() { int n, m; scanf("%d%d", &n, &m); int cid = 0, t = 1, d2 = 0, d4 = 0; while (m--) { int cd = readcard(); //printf("cd=%d\n", cd); if ((d2 > 0 && cd != DRW2) || (d4 > 0 && cd != DRW4)) { cns[cid] -= (d2 + d4); d2 = d4 = 0; cid = next_card(cid, t, n); } cns[cid]++; if (cd == SKIP) cid = next_card(cid, t, n); else if (cd == REV) t *= -1; else if (cd == DRW2) d2 += 2; else if (cd == DRW4) d4 += 4; cid = next_card(cid, t, n); } cid = prev_card(cid, t, n); printf("%d %d\n", cid + 1, cns[cid]); return 0; }