#include <bits/stdc++.h>
using namespace std;
struct Tree {
  int m, d;
  Tree *L, *R;
  Tree(int _m) : m(_m), d(0), L(0), R(0) {}
};
Tree *tv, *th;
int n, q;
void push(Tree *T) {
  T->m = max(T->m, T->d);
  if (T->L) T->L->d = max(T->L->d, T->d);
  if (T->R) T->R->d = max(T->R->d, T->d);
}
int qry(Tree *T, int l, int r, int idx) {
  push(T);
  int mid = (l + r) >> 1;
  if (T->L && idx < mid) {
    return max(qry(T->L, l, mid, idx), T->m);
  }
  if (T->R && idx >= mid) {
    return max(qry(T->R, mid, r, idx), T->m);
  }
  return T->m;
}
void upd(Tree *T, int l, int r, int I, int J, int val) {
  push(T);
  if (J <= l || r <= I) return;
  if (I <= l && J >= r) {
    T->d = val;
    return;
  }
  if (!T->L) {
    T->L = new Tree(T->m);
    T->R = new Tree(T->m);
  }
  int mid = (l + r) >> 1;
  upd(T->L, l, mid, I, J, val);
  upd(T->R, mid, r, I, J, val);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  tv = new Tree(0);
  th = new Tree(0);
  for (int i = 0; i < q; i++) {
    int x, y, z;
    char ch;
    cin >> x >> y >> ch;
    if (ch == 'U') {
      z = qry(tv, 1, n + 1, x);
      cout << y - z << endl;
      upd(th, 1, n + 1, z + 1, y + 1, x);
      upd(tv, 1, n + 1, x, x + 1, y);
    } else {
      z = qry(th, 1, n + 1, y);
      cout << x - z << endl;
      upd(tv, 1, n + 1, z + 1, x + 1, y);
      upd(th, 1, n + 1, y, y + 1, x);
    }
  }
  return 0;
}
