#include <bits/stdc++.h>
const int MAXN = 2e5 + 10;
template <int N>
struct SegmentTree {
  static const int M = N << 2;
  int tag[M], max[M];
  inline void modify(int x, int val) {
    max[x] = std::max(max[x], val), tag[x] = std::max(tag[x], val);
  }
  inline void pushUp(int x) {
    max[x] = std::max(max[((x) << 1)], max[((x) << 1 | 1)]);
  }
  inline void pushDown(int x) {
    if (tag[x]) {
      modify(((x) << 1), tag[x]), modify(((x) << 1 | 1), tag[x]), tag[x] = 0;
    }
  }
  void update(int x, int L, int R, int ql, int qr, int val) {
    if (ql > qr) return;
    if (ql <= L && R <= qr) return modify(x, val);
    int mid = L + R >> 1;
    pushDown(x);
    if (ql <= mid) update(((x) << 1), L, mid, ql, qr, val);
    if (qr > mid) update(((x) << 1 | 1), mid + 1, R, ql, qr, val);
    return pushUp(x);
  }
  int query(int x, int L, int R, int pos) {
    if (L == R) return max[x];
    int mid = L + R >> 1;
    pushDown(x);
    return pos <= mid ? query(((x) << 1), L, mid, pos)
                      : query(((x) << 1 | 1), mid + 1, R, pos);
  }
};
SegmentTree<MAXN> T1, T2;
int n, Q, cnt1, cnt2;
int x[MAXN], y[MAXN], op[MAXN], tmp[MAXN], rx[MAXN], ry[MAXN];
int main() {
  scanf("%d%d", &n, &Q);
  for (int i = 1; i <= Q; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    char ch = getchar();
    while (ch != 'L' && ch != 'U') ch = getchar();
    op[i] = ch == 'L' ? 1 : 2;
  }
  std::copy(x + 1, x + Q + 1, tmp + 1), std::sort(tmp + 1, tmp + Q + 1);
  int m = std::unique(tmp + 1, tmp + Q + 1) - tmp - 1;
  for (int i = 1, awa; i <= Q; ++i)
    awa = std::lower_bound(tmp + 1, tmp + m + 1, x[i]) - tmp, rx[awa] = x[i],
    x[i] = awa;
  for (int i = 1; i <= Q; ++i) ry[m - x[i] + 1] = y[i], y[i] = m - x[i] + 1;
  for (int i = 1; i <= Q; ++i) {
    if (op[i] == 1) {
      int max = T1.query(1, 1, m, y[i]);
      printf("%d\n", rx[x[i]] - rx[max]);
      T1.update(1, 1, m, y[i], y[i], x[i]);
      T2.update(1, 1, m, max + 1, x[i], y[i]);
    } else {
      int max = T2.query(1, 1, m, x[i]);
      printf("%d\n", ry[y[i]] - ry[max]);
      T2.update(1, 1, m, x[i], x[i], y[i]);
      T1.update(1, 1, m, max + 1, y[i], x[i]);
    }
  }
  return 0;
}
