#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 (l[i][0] == 'n') { if (stack > 0) { cnt[now] -= stack; stack = 0; now = (now + n + step) % n; cnt[now]++; now = (now + n + step) % n; } else { cnt[now]++; now = (now + n + step) % n; } } else if (l[i][0] == 's') { if (stack > 0) { cnt[now] -= stack; stack = 0; now = (now + n + step) % n; cnt[now]++; now = (now + n + step) % n; now = (now + n + step) % n; } else { cnt[now]++; now = (now + n + step) % n; now = (now + n + step) % n; } } else if (l[i][0] == 'r') { if (stack > 0) { cnt[now] -= stack; stack = 0; now = (now + n + step) % n; cnt[now]++; step *= -1; now = (now + n + step) % n; } else { cnt[now]++; step *= -1; now = (now + n + step) % n; } } else if (l[i][4] == 't') { if (i > 0) { if (l[i - 1][0] == 'd' && l[i - 1][4] == 't') { cnt[now]++; stack += 2; now = (now + n + step) % n; } else { if (stack > 0) { cnt[now] -= stack; stack = 0; now = (now + n + step) % n; cnt[now]++; stack += 2; now = (now + n + step) % n; } else { cnt[now]++; stack += 2; now = (now + n + step) % n; } } } else { cnt[now]++; stack += 2; now = (now + n + step) % n; } } else { if (i > 0) { if (l[i - 1][0] == 'd' && l[i - 1][4] == 'f') { cnt[now]++; stack += 4; now = (now + n + step) % n; } else { if (stack > 0) { cnt[now] -= stack; stack = 0; now = (now + n + step) % n; cnt[now]++; stack += 4; now = (now + n + step) % n; } else { cnt[now]++; stack += 4; now = (now + n + step) % n; } } } 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; }