#include <bits/stdc++.h>
using namespace std;
const int MOD(1000000007);
const int INF((1 << 30) - 1);
const int MAXN(200005);
int x[MAXN], y[MAXN], numx[MAXN], numy[MAXN], t[2][4 * MAXN];
char c[MAXN];
map<int, int> tx, ty, kx, ky;
map<pair<int, int>, bool> used;
void init(int i, int f, int l, int c) {
  t[c][i] = -INF;
  if (f == l) return;
  int m = (f + l) / 2;
  init(i * 2, f, m, c);
  init(i * 2 + 1, m + 1, l, c);
}
int query(int i, int f, int l, int pos, int c) {
  if (f == l) return t[c][i];
  int m = (f + l) / 2;
  if (pos <= m) return max(t[c][i], query(i * 2, f, m, pos, c));
  return max(t[c][i], query(i * 2 + 1, m + 1, l, pos, c));
}
void update(int i, int f, int l, int st, int fn, int val, int c) {
  if (f == st && l == fn) {
    t[c][i] = max(t[c][i], val);
    return;
  }
  int m = (f + l) / 2;
  if (fn <= m)
    update(i * 2, f, m, st, fn, val, c);
  else if (st > m)
    update(i * 2 + 1, m + 1, l, st, fn, val, c);
  else {
    update(i * 2, f, m, st, m, val, c);
    update(i * 2 + 1, m + 1, l, m + 1, fn, val, c);
  }
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < q; i++) {
    scanf("%d%d %c", &x[i], &y[i], &c[i]);
    tx[x[i]] = 1;
    ty[y[i]] = 1;
  }
  int numX = 0;
  for (typeof(tx.begin()) it = tx.begin(); it != tx.end(); it++) {
    kx[it->first] = ++numX;
    numx[numX] = it->first;
  }
  int numY = 0;
  for (typeof(ty.begin()) it = ty.begin(); it != ty.end(); it++) {
    ky[it->first] = ++numY;
    numy[numY] = it->first;
  }
  init(1, 1, numX, 0);
  init(1, 1, numY, 1);
  for (int i = 0; i < q; i++) {
    if (used[pair<int, int>(x[i], y[i])]) {
      printf("0\n");
      continue;
    }
    used[pair<int, int>(x[i], y[i])] = 1;
    int first = kx[x[i]], second = ky[y[i]];
    if (c[i] == 'U') {
      int k = query(1, 1, numX, first, 0);
      if (k == -INF) {
        printf("%d\n", y[i]);
        update(1, 1, numY, 1, second, first, 1);
      } else {
        printf("%d\n", y[i] - numy[k]);
        update(1, 1, numY, k, second, first, 1);
      }
    } else {
      int k = query(1, 1, numY, second, 1);
      if (k == -INF) {
        printf("%d\n", x[i]);
        update(1, 1, numX, 1, first, second, 0);
      } else {
        printf("%d\n", x[i] - numx[k]);
        update(1, 1, numX, k, first, second, 0);
      }
    }
  }
}
