#include #include int main() { int N, M; std::cin >> N >> M; std::vector l(M); for (int i = 0; i < M; i++) { std::cin >> l[i]; } std::vector pay(N, 0); int p = 0, t = 0, rot = 1; for (; t < M;) { if (l[t] == "number") { pay[p]++, t++; } else if (l[t] == "drawtwo") { int cost = 0; for (; t < M and l[t] == "drawtwo"; t++, cost += 2, (p += rot) %= N) { pay[p]++; } pay[p] -= cost; } else if (l[t] == "drawfour") { int cost = 0; for (; t < M and l[t] == "drawfour"; t++, cost += 4, (p += rot) %= N) { pay[p]++; } pay[p] -= cost; } else if (l[t] == "skip") { pay[p]++, t++, (p += rot) %= N; } else { pay[p]++, t++, rot = (N - rot); } (p += rot) %= N; } (p += N - rot) %= N; std::cout << p + 1 << " " << pay[p] << std::endl; return 0; }