#include <bits/stdc++.h>
using namespace std;
int x[400010], y[400010], op[400010], hashx[400010], hashy[400010],
    cnt1 = 0, cnt2 = 0, Max[2][400010 << 2], lazy[2][400010 << 2];
map<pair<int, int>, bool> M;
void pushdown(int i, int type) {
  if (lazy[type][i]) {
    lazy[type][i << 1] = max(lazy[type][i << 1], lazy[type][i]);
    lazy[type][(i << 1) | 1] = max(lazy[type][(i << 1) | 1], lazy[type][i]);
    Max[type][i << 1] = max(Max[type][i << 1], lazy[type][i]);
    Max[type][(i << 1) | 1] = max(Max[type][(i << 1) | 1], lazy[type][i]);
    lazy[type][i] = 0;
  }
}
void update(int i, int l, int r, int a, int b, int d, int type) {
  if (l == a && r == b) {
    Max[type][i] = max(Max[type][i], d);
    lazy[type][i] = max(lazy[type][i], d);
  } else {
    pushdown(i, type);
    int mid = (l + r) >> 1;
    if (b <= mid)
      update(i << 1, l, mid, a, b, d, type);
    else if (a > mid)
      update((i << 1) | 1, mid + 1, r, a, b, d, type);
    else {
      update(i << 1, l, mid, a, mid, d, type);
      update((i << 1) | 1, mid + 1, r, mid + 1, b, d, type);
    }
    Max[type][i] = max(Max[type][i << 1], Max[type][(i << 1) | 1]);
  }
}
int query(int i, int l, int r, int x, int type) {
  if (x < l || x > r) return 0;
  if (l == r) return Max[type][i];
  pushdown(i, type);
  int mid = (l + r) >> 1;
  if (x <= mid) return query(i << 1, l, mid, x, type);
  return query((i << 1) | 1, mid + 1, r, x, type);
}
int main() {
  int n, q;
  char buf[5];
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d%s", y + i, x + i, buf);
    if (buf[0] == 'U')
      op[i] = 1;
    else
      op[i] = 2;
    hashx[i] = x[i];
    hashy[i] = y[i];
  }
  sort(hashx + 1, hashx + q + 1);
  sort(hashy + 1, hashy + q + 1);
  cnt1 = unique(hashx + 1, hashx + q + 1) - hashx - 1;
  cnt2 = unique(hashy + 1, hashy + q + 1) - hashy - 1;
  for (int i = 1; i <= q; ++i) {
    x[i] = lower_bound(hashx + 1, hashx + cnt1 + 1, x[i]) - hashx;
    y[i] = lower_bound(hashy + 1, hashy + cnt2 + 1, y[i]) - hashy;
  }
  for (int i = 1; i <= q; ++i)
    if (M.find(make_pair(x[i], y[i])) != M.end())
      puts("0");
    else {
      M[make_pair(x[i], y[i])] = 1;
      if (op[i] == 1) {
        int xx = query(1, 1, cnt2, y[i], 0);
        printf("%d\n", hashx[x[i]] - hashx[xx]);
        if (xx == 0) ++xx;
        update(1, 1, cnt1, xx, x[i], y[i], 1);
      } else {
        int yy = query(1, 1, cnt1, x[i], 1);
        printf("%d\n", hashy[y[i]] - hashy[yy]);
        if (yy == 0) ++yy;
        update(1, 1, cnt2, yy, y[i], x[i], 0);
      }
    }
  return 0;
}
