#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 2 * 200010;
int tree[2][4 * MAXN];
int lazy[2][4 * MAXN];
int coords[MAXN];
int X[MAXN], Y[MAXN];
char OP[MAXN];
void go(int idx, int l, int r, int tree[], int lazy[]) {
  if (lazy[idx] != 0) {
    tree[idx] = max(tree[idx], lazy[idx]);
    if (l != r) {
      lazy[2 * idx] = max(lazy[2 * idx], lazy[idx]);
      lazy[2 * idx + 1] = max(lazy[2 * idx + 1], lazy[idx]);
    }
    lazy[idx] = 0;
  }
}
void update(int px, int py, int val, int idx, int l, int r, int tree[],
            int lazy[]) {
  go(idx, l, r, tree, lazy);
  if (py < l || px > r) return;
  if (l >= px && r <= py) {
    tree[idx] = max(tree[idx], val);
    if (l != r) {
      lazy[2 * idx] = max(lazy[2 * idx], val);
      lazy[2 * idx + 1] = max(lazy[2 * idx + 1], val);
    }
    return;
  }
  int m = (l + r) / 2;
  update(px, py, val, 2 * idx, l, m, tree, lazy);
  update(px, py, val, 2 * idx + 1, m + 1, r, tree, lazy);
  tree[idx] = max(tree[2 * idx], tree[2 * idx + 1]);
}
int query(int px, int py, int idx, int l, int r, int tree[], int lazy[],
          int tgt) {
  if (py < l || px > r) {
    return 0;
  }
  go(idx, l, r, tree, lazy);
  if (l >= px && r <= py) {
    return tree[idx];
  }
  int m = (l + r) / 2;
  int p1 = query(px, py, 2 * idx, l, m, tree, lazy, tgt);
  int p2 = query(px, py, 2 * idx + 1, m + 1, r, tree, lazy, tgt);
  return max(p1, p2);
}
int main() {
  ios::sync_with_stdio(false);
  int n, q, sz = 0;
  cin >> n >> q;
  coords[sz++] = 1;
  coords[sz++] = 0;
  for (int i = 0; i < (q); ++i) {
    cin >> X[i] >> Y[i] >> OP[i];
    coords[sz++] = X[i];
    coords[sz++] = X[i] + 1;
    coords[sz++] = Y[i];
    coords[sz++] = Y[i] + 1;
  }
  sort(coords, coords + sz);
  sz = unique(coords, coords + sz) - coords;
  set<pair<pair<int, int>, char> > migue;
  for (int i = 0; i < (q); ++i) {
    int ox = X[i];
    int oy = Y[i];
    char op = OP[i];
    if (migue.count({{ox, oy}, op})) {
      cout << "0" << endl;
      continue;
    }
    migue.insert({{ox, oy}, op});
    int x = lower_bound(coords, coords + sz, ox) - coords;
    int y = lower_bound(coords, coords + sz, oy) - coords;
    if (op == 'L') {
      int val = query(y, y, 1, 0, sz - 1, tree[1], lazy[1], x);
      if (val == x) {
        cout << 0 << endl;
        continue;
      }
      val = val + 1;
      int dif = coords[x] - coords[val] + 1;
      cout << dif << endl;
      update(val, x, y, 1, 0, sz - 1, tree[0], lazy[0]);
    } else {
      int val = query(x, x, 1, 0, sz - 1, tree[0], lazy[0], y);
      if (val == y) {
        cout << 0 << endl;
        continue;
      }
      val = val + 1;
      int dif = coords[y] - coords[val] + 1;
      cout << dif << endl;
      update(val, y, x, 1, 0, sz - 1, tree[1], lazy[1]);
    }
  }
  return 0;
}
