#include <bits/stdc++.h>
using namespace std;
const long long N = 400010;
char t[10];
map<long long, long long> mp[3];
long long n, q, col;
long long s[N], xx[N], yy[N], op[N], ff[N], gg[N];
struct Point {
  long long x, op, id;
} X[N], Y[N];
inline bool cmp(Point A, Point B) { return A.x < B.x; }
struct SegmentTree {
  long long tag[N << 2], mx[N << 2];
  inline void pushdown(long long u) {
    if (!tag[u]) return;
    mx[(u << 1)] = max(mx[(u << 1)], tag[u]);
    mx[(u << 1 | 1)] = max(mx[(u << 1 | 1)], tag[u]);
    tag[(u << 1)] = max(tag[(u << 1)], tag[u]);
    tag[(u << 1 | 1)] = max(tag[(u << 1 | 1)], tag[u]), tag[u] = 0;
  }
  inline void change(long long u, long long l, long long r, long long L,
                     long long R, long long v) {
    if (l >= L && r <= R) {
      mx[u] = max(mx[u], v);
      tag[u] = max(tag[u], v);
      return;
    }
    long long mid = l + r >> 1;
    pushdown(u);
    if (L <= mid) change((u << 1), l, mid, L, R, v);
    if (mid < R) change((u << 1 | 1), mid + 1, r, L, R, v);
    mx[u] = max(mx[(u << 1)], mx[(u << 1 | 1)]);
  }
  inline long long query(long long u, long long l, long long r, long long pos) {
    if (l == r) return mx[u];
    long long mid = l + r >> 1;
    pushdown(u);
    if (pos <= mid)
      return query((u << 1), l, mid, pos);
    else
      return query((u << 1 | 1), mid + 1, r, pos);
  }
} R, C;
inline void calcX(long long x) {
  xx[X[x].id] = col;
  op[X[x].id] = X[x].op;
  ff[col] = X[x].x;
}
inline void calcY(long long x) {
  yy[Y[x].id] = col;
  op[Y[x].id] = Y[x].op;
  gg[col] = Y[x].x;
}
signed main() {
  cin >> n >> q;
  for (long long i = 1; i <= q; i++) {
    long long x, y;
    char t;
    cin >> x >> y >> t;
    if (t == 'U') X[i] = (Point){x, 1, i}, Y[i] = (Point){y, 1, i};
    if (t == 'L') X[i] = (Point){x, 2, i}, Y[i] = (Point){y, 2, i};
  }
  sort(X + 1, X + q + 1, cmp), col++, calcX(1);
  for (long long i = 2; i <= q; i++) {
    if (X[i].x > X[i - 1].x) ++col;
    calcX(i);
  }
  long long m = col;
  col = 0;
  sort(Y + 1, Y + q + 1, cmp), col++, calcY(1);
  for (long long i = 2; i <= q; i++) {
    if (Y[i].x > Y[i - 1].x) col++;
    calcY(i);
  }
  m = max(m, col) + 100000;
  for (long long i = 1; i <= q; i++) {
    if (op[i] == 1) {
      if (mp[1][xx[i]]) {
        puts("0");
        continue;
      }
      long long ls = R.query(1, 1, m, xx[i]);
      mp[1][xx[i]] = 1;
      C.change(1, 1, m, ls + 1, yy[i], xx[i]);
      cout << n - ff[xx[i]] + 1 - gg[ls] << endl;
    }
    if (op[i] == 2) {
      if (mp[2][yy[i]]) {
        puts("0");
        continue;
      }
      long long ls = C.query(1, 1, m, yy[i]);
      mp[2][yy[i]] = 1;
      R.change(1, 1, m, ls + 1, xx[i], yy[i]);
      cout << n - gg[yy[i]] + 1 - ff[ls] << endl;
    }
  }
  return 0;
}
