template <typename T> inlinevoidread(T &x){ x = 0; int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; x *= f; }
int n, q, sum[N], a[N], mx[2], l[N], r[N]; char c[N];
inlinevoidupdate(int x, int lp, int rp){ if (mx[x & 1] < x) mx[x & 1] = x, l[x] = lp, r[x] = rp; }
intmain(){ read(n), read(q); scanf("%s", c + 1); for (int i = 1; i <= n; ++ i) a[i] = c[i] == 'T' ? 2 : 1; for (int i = 1; i <= n; ++ i) sum[i] = sum[i - 1] + a[i]; for (int i = n; i >= 1; -- i) update(sum[i], 1, i); for (int i = 1; i <= n; ++ i) update(sum[n] - sum[i - 1], i, n); for (int i = mx[1] - 2; i > 0; i -= 2) get_pos(i); for (int i = mx[0] - 2; i > 0; i -= 2) get_pos(i); while (q --) { int x = 0; read(x); if (x > mx[x & 1]) printf("NIE\n"); elseprintf("%d %d\n", l[x], r[x]); } return (0 - 0); }