#include #include #define show(x) std::cerr << #x << " = " << (x) << std::endl template std::ostream& operator<<(std::ostream& os, const std::vector& v) { os << "["; for (const auto& p : v) { os << p << ","; } return (os << "]\n"); } 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; (p += rot) %= N) { 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); } } show(pay); p = (l.back().front() == 'd' or l.back().front() == 's' ? (p + 2 * N - 2 * rot) % N : (p + N - 1) % N); std::cout << p + 1 << " " << pay[p] << std::endl; return 0; }