#include #include #include using namespace std; void next(bool isReverse, int N, int &turn) { if (isReverse) { --turn; if (turn < 0) turn += N; } else ++turn; turn %= N; } int main() { bool isReverse = false, draw = true; int N, M, turn = 0, two = 0, four = 0; cin >> N >> M; vector drunkard(N); vector l(M); for (int i = 0; i < M; ++i) cin >> l[i]; for (int i = 0; i < M - 1; ++i) { //cout << turn + 1 << ' ' << isReverse << ' ' << l[i] << ' ' << two << ' ' << four << ' ' << draw << endl; if (/*draw && */two != 0 && l[i - 1] == "drawtwo" && l[i] != "drawtwo") { drunkard[turn] -= two; two = 0; next(isReverse, N, turn); draw = !draw; --i; continue; } if (/*draw && */four != 0 && l[i - 1] == "drawfour" && l[i] != "drawfour") { drunkard[turn] -= four; four = 0; next(isReverse, N, turn); draw = !draw; --i; continue; } draw = true; ++drunkard[turn]; if (l[i] == "drawtwo") two += 2; else if (l[i] == "drawfour") four += 4; else if (l[i] == "reverse") isReverse = !isReverse; else if (l[i] == "skip") { if (isReverse) --turn; else ++turn; } next(isReverse, N, turn); } cout << turn + 1 << ' ' << drunkard[turn] + 1; }