#include <bits/stdc++.h>
using namespace std;
const int maxn = 200009;
int X[maxn << 2], Y[maxn << 2], lazyX[maxn << 2], lazyY[maxn << 2];
int x[maxn], y[maxn], m, n, p, a[maxn], b[maxn];
char dir[maxn];
void update(int T[], int lazy[], int o, int l, int r, int x, int y, int z) {
  if (l == x && y == r) {
    T[o] = max(T[o], z);
    lazy[o] = max(lazy[o], z);
    return;
  }
  T[(o << 1)] = max(T[(o << 1)], lazy[o]);
  lazy[(o << 1)] = max(lazy[(o << 1)], lazy[o]);
  T[(o << 1 | 1)] = max(T[(o << 1 | 1)], lazy[o]);
  lazy[(o << 1 | 1)] = max(lazy[(o << 1 | 1)], lazy[o]);
  if (x <= ((l + r) >> 1))
    update(T, lazy, (o << 1), l, ((l + r) >> 1), x, min(((l + r) >> 1), y), z);
  if (((l + r) >> 1) + 1 <= y)
    update(T, lazy, (o << 1 | 1), ((l + r) >> 1) + 1, r,
           max(((l + r) >> 1) + 1, x), y, z);
  T[o] = max(T[(o << 1)], T[(o << 1 | 1)]);
}
int query(int T[], int lazy[], int o, int l, int r, int x) {
  if (l == r) return T[o];
  T[(o << 1)] = max(T[(o << 1)], lazy[o]);
  lazy[(o << 1)] = max(lazy[(o << 1)], lazy[o]);
  T[(o << 1 | 1)] = max(T[(o << 1 | 1)], lazy[o]);
  lazy[(o << 1 | 1)] = max(lazy[(o << 1 | 1)], lazy[o]);
  if (x <= ((l + r) >> 1))
    return query(T, lazy, (o << 1), l, ((l + r) >> 1), x);
  return query(T, lazy, (o << 1 | 1), ((l + r) >> 1) + 1, r, x);
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i], &y[i]);
    getchar();
    dir[i] = getchar();
    a[i] = x[i];
    b[i] = y[i];
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(a + 1, a + n + 1, x[i]) - a;
    y[i] = lower_bound(b + 1, b + n + 1, y[i]) - b;
  }
  for (int i = 1; i <= n; i++)
    if (dir[i] == 'L') {
      p = query(X, lazyX, 1, 1, n, y[i]);
      printf("%d\n", a[x[i]] - a[p]);
      update(Y, lazyY, 1, 1, n, p + 1, x[i], y[i]);
      update(X, lazyX, 1, 1, n, y[i], y[i], x[i]);
    } else {
      p = query(Y, lazyY, 1, 1, n, x[i]);
      printf("%d\n", b[y[i]] - b[p]);
      update(X, lazyX, 1, 1, n, p + 1, y[i], x[i]);
      update(Y, lazyY, 1, 1, n, x[i], x[i], y[i]);
    }
  return 0;
}
