#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
struct SegmentTree {
  int tree[N << 2];
  int lazy[N << 2];
  inline void push_down(int rt) {
    if (lazy[rt] > tree[rt]) tree[rt] = lazy[rt];
    lazy[rt << 1] = max(lazy[rt << 1], lazy[rt]);
    lazy[rt << 1 | 1] = max(lazy[rt << 1 | 1], lazy[rt]);
    lazy[rt] = 0;
  }
  void update(int v, int ll, int rr, int l, int r, int rt) {
    if (ll <= l && rr >= r) return void(lazy[rt] = max(lazy[rt], v));
    if (lazy[rt]) push_down(rt);
    int m = (l + r) >> 1;
    if (ll <= m) update(v, ll, rr, l, m, rt << 1);
    if (rr > m) update(v, ll, rr, m + 1, r, rt << 1 | 1);
  }
  int query(int x, int l, int r, int rt) {
    if (lazy[rt]) push_down(rt);
    if (l == r) return tree[rt];
    int m = (l + r) >> 1;
    if (x <= m)
      return query(x, l, m, rt << 1);
    else
      return query(x, m + 1, r, rt << 1 | 1);
  }
} tx, ty;
struct Q {
  int x, y;
  char d;
  void read() { cin >> x >> y >> d; }
} q[N];
pair<int, int> x[N], y[N];
map<int, int> posx, posy;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    q[i].read();
    x[i] = {q[i].x, i};
    y[i] = {q[i].y, i};
  }
  sort(x, x + m);
  sort(y, y + m);
  int cx = 1, cy = 1;
  for (int i = 0; i < m; i++) {
    posx[x[i].first] = cx;
    if (x[i].first != x[i + 1].first) cx++;
    posy[y[i].first] = cy;
    if (y[i].first != y[i + 1].first) cy++;
  }
  for (int i = 0; i < m; i++) {
    int ey = ty.query(posy[q[i].y], 1, m, 1);
    int ex = tx.query(posx[q[i].x], 1, m, 1);
    if (ey == q[i].x || ex == q[i].y) {
      cout << 0 << endl;
      continue;
    }
    if (q[i].d == 'U') {
      cout << q[i].y - ex << endl;
      ty.update(q[i].x, posy[ex] + 1, posy[q[i].y], 1, m, 1);
    } else {
      cout << q[i].x - ey << endl;
      tx.update(q[i].y, posx[ey] + 1, posx[q[i].x], 1, m, 1);
    }
  }
  return 0;
}
