#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); ll n, m; cin >> n >> m; vector l(m); rep(i, m) cin >> l[i]; vector c(n, 0); ll win = 0, cur = 0, next = 1, dt = 0, df = 0; rep(i, m) { win = cur; if ((dt > 0) && (l[i] != "drawtwo")) { c[cur] -= dt * 2; dt = 0; cur++; } else if ((df > 0) && (l[i] != "drawfour")) { c[cur] -= df * 4; df = 0; cur++; } if (l[i] == "number") { c[cur]++; cur = (cur + n + next) % n; } else if (l[i] == "drawtwo") { c[cur]++; dt++; cur = (cur + n + next) % n; } else if (l[i] == "drawfour") { c[cur]++; df++; cur = (cur + n + next) % n; } else if (l[i] == "skip") { c[cur]++; cur = (cur + n + next * 2) % n; } else if (l[i] == "reverse") { c[cur]++; next *= -1; cur = (cur + n + next) % n; } } printf("%lld %lld\n", win + 1, c[win]); return 0; }