#include <bits/stdc++.h>
using namespace std;
struct node {
  int val;
  int lazy;
  node *l;
  node *r;
  node(node *x, node *y, int v, int ll) {
    l = x;
    r = y;
    val = v;
    lazy = ll;
  }
};
int gv(node *x) {
  if (x == NULL) return 0;
  return x->val;
}
int gl(node *x) {
  if (x == NULL) return 0;
  return x->lazy;
}
void updatecol(node *&x, int start, int end, int i, int j, int val) {
  if (start > j || end < i) return;
  if (x == NULL) {
    x = new node(NULL, NULL, 0, 0);
  }
  if (start >= i && end <= j) {
    x->lazy = max(x->lazy, val);
    return;
  }
  updatecol(x->l, start, (start + end) / 2, i, j, val);
  updatecol(x->r, (start + end) / 2 + 1, end, i, j, val);
  x->val = max(gv(x->l), gv(x->r));
  x->val = max(x->val, gl(x->l));
  x->val = max(x->val, gl(x->r));
}
void updaterow(node *&x, int start, int end, int i, int j, int val) {
  if (start > j || end < i) return;
  if (x == NULL) {
    x = new node(NULL, NULL, 0, 0);
  }
  if (start >= i && end <= j) {
    x->lazy = max(x->lazy, val);
    return;
  }
  updaterow(x->l, start, (start + end) / 2, i, j, val);
  updaterow(x->r, (start + end) / 2 + 1, end, i, j, val);
  x->val = max(gv(x->l), gv(x->r));
  x->val = max(x->val, gl(x->l));
  x->val = max(x->val, gl(x->r));
}
int queryrow(node *&x, int start, int end, int i) {
  if (start > i || end < i) return 0;
  if (x == NULL) return 0;
  if (start == end) return max(x->lazy, x->val);
  return max(x->lazy, queryrow(x->l, start, (start + end) / 2, i) +
                          queryrow(x->r, (start + end) / 2 + 1, end, i));
}
int querycol(node *&x, int start, int end, int i) {
  if (start > i || end < i) return 0;
  if (x == NULL) return 0;
  if (start == end) return max(x->lazy, x->val);
  return max(x->lazy, querycol(x->l, start, (start + end) / 2, i) +
                          querycol(x->r, (start + end) / 2 + 1, end, i));
}
node *rows;
node *cols;
map<long long, int> vis;
int main() {
  ios_base::sync_with_stdio(0);
  int n, q;
  cin >> n >> q;
  for (int g = 0; g < q; g++) {
    int x, y;
    cin >> x >> y;
    swap(x, y);
    char t;
    cin >> t;
    if (vis[1LL * (1e9 + 1) * (int)(t - 'A') + x]) {
      cout << 0 << '\n';
      continue;
    }
    vis[1LL * (1e9 + 1) * (int)(t - 'A') + x] = 1;
    if (t == 'L') {
      int o = queryrow(rows, 1, n, x);
      if (o >= y) {
        cout << 0 << '\n';
        continue;
      }
      cout << y - o << '\n';
      updaterow(rows, 1, n, x, x, y);
      updatecol(cols, 1, n, o, y, x);
    } else {
      int o = querycol(cols, 1, n, y);
      if (o >= x) {
        cout << 0 << '\n';
        continue;
      }
      cout << x - o << '\n';
      updatecol(cols, 1, n, y, y, x);
      updaterow(rows, 1, n, o, x, y);
    }
  }
  return 0;
}
