#include int main() { int n, m; scanf("%d %d", &n, &m); char l[300005][16]; int i; for (i = 0; i < m; i++) scanf("%s", l[i]); int now = 0, step = 1, stack = 0; int cnt[100005]; 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][4] == 'e') cnt[now]++; else if (l[i][4] == '\0') { cnt[now]++; now = (now + n + step) % n; } else if (l[i][4] == 'r') { cnt[now]++; step *= -1; } else if (l[i][4] == 't') { cnt[now]++; stack += 2; } else if (l[i][4] == 'f') { cnt[now]++; stack += 4; } now = (now + n + step) % n; } now = (now + n - step) % n; if(l[m-1][4]=='\0') now = (now + n - step) % n; printf("%d %d\n", now + 1, cnt[now]); return 0; }