#include int main() { int n, m; scanf("%d %d", &n, &m); char l[3005][16]; int i; for (i = 0; i < m; i++) scanf("%s", l[i]); int now = 0, step = 1, stack = 0; int cnt[1005]; for (i = 0; i < n; i++) cnt[i] = 0; for (i = 0; i < m; i++) { if (stack > 0) { if (l[i - 1][4] != l[i][4]) { cnt[now] -= stack; stack = 0; now = (now + n + step) % n; } } if (l[i][0] == 'n') cnt[now]++; else if (l[i][0] == 's') { cnt[now]++; now = (now + n + step) % n; } else if (l[i][0] == 'r') { cnt[now]++; step *= -1; } else if (l[i][4] == 't') { cnt[now]++; stack += 2; } else { cnt[now]++; stack += 4; } now = (now + n + step) % n; } now = (now + n - step) % n; printf("%d %d\n", now + 1, cnt[now]); return 0; }