#include <bits/stdc++.h>
using namespace std;
const int MAXN = 400010;
struct TREE {
  int l, r;
  int val, mark;
  int mid() { return (l + r) >> 1; }
} tree[2][MAXN << 2];
void pushdown(int k, int op) {
  if (tree[op][k].mark) {
    tree[op][(k << 1)].val = max(tree[op][(k << 1)].val, tree[op][k].mark);
    tree[op][(k << 1 | 1)].val =
        max(tree[op][(k << 1 | 1)].val, tree[op][k].mark);
    tree[op][(k << 1)].mark = max(tree[op][(k << 1)].mark, tree[op][k].mark);
    tree[op][(k << 1 | 1)].mark =
        max(tree[op][k].mark, tree[op][(k << 1 | 1)].mark);
    tree[op][k].mark = 0;
  }
}
void build(int l, int r, int k, int op) {
  tree[op][k].l = l;
  tree[op][k].r = r;
  tree[op][k].val = 0;
  tree[op][k].mark = 0;
  if (l == r) return;
  int mid = tree[op][k].mid();
  build(l, mid, (k << 1), op);
  build(mid + 1, r, (k << 1 | 1), op);
}
void update(int l, int r, int k, int val, int op) {
  if (tree[op][k].l >= l && tree[op][k].r <= r) {
    tree[op][k].mark = max(tree[op][k].mark, val);
    tree[op][k].val = max(tree[op][k].val, val);
    return;
  }
  pushdown(k, op);
  int mid = tree[op][k].mid();
  if (r <= mid)
    update(l, r, (k << 1), val, op);
  else if (l > mid)
    update(l, r, (k << 1 | 1), val, op);
  else {
    update(l, mid, (k << 1), val, op);
    update(mid + 1, r, (k << 1 | 1), val, op);
  }
}
int query(int pos, int k, int op) {
  if (tree[op][k].l == tree[op][k].r) return tree[op][k].val;
  pushdown(k, op);
  int mid = tree[op][k].mid();
  if (pos <= mid)
    return query(pos, (k << 1), op);
  else
    return query(pos, (k << 1 | 1), op);
}
int vec[MAXN], idx;
int HASH(int val) {
  int l = 0, r = idx;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (vec[mid] == val) return mid;
    if (vec[mid] < val)
      l = mid + 1;
    else
      r = mid - 1;
  }
  return l;
}
int n, m;
int x[MAXN / 2], y[MAXN / 2], op[MAXN / 2];
void solve() {
  int i;
  int cnt = 0;
  for (i = 0; i < m; i++) {
    char str[2];
    scanf("%d%d%s", &x[i], &y[i], str);
    vec[++cnt] = x[i];
    vec[++cnt] = y[i];
    if (str[0] == 'U')
      op[i] = 0;
    else
      op[i] = 1;
  }
  sort(vec + 1, vec + cnt + 1);
  idx = 1;
  for (i = 2; i <= cnt; i++)
    if (vec[idx] != vec[i]) vec[++idx] = vec[i];
  build(1, idx, 1, 0);
  build(1, idx, 1, 1);
  for (i = 0; i < m; i++) {
    int ans = 0;
    if (i == 3) i = 3;
    if (op[i] == 0) {
      int res = query(HASH(x[i]), 1, 0);
      ans += y[i] - res;
      if (ans) {
        int temp = HASH(x[i]);
        update(temp, temp, 1, y[i], 0);
        int a = HASH(res);
        update(a + 1, HASH(y[i]), 1, x[i], 1);
      }
    } else {
      int res = query(HASH(y[i]), 1, 1);
      ans += x[i] - res;
      if (ans) {
        int temp = HASH(y[i]);
        update(temp, temp, 1, x[i], 1);
        update(HASH(res) + 1, HASH(x[i]), 1, y[i], 0);
      }
    }
    printf("%d\n", ans);
  }
}
int main() {
  while (scanf("%d%d", &n, &m) == 2) solve();
  return 0;
}
