#include <bits/stdc++.h>
using namespace std;
map<int, int> r;
int x[200010], y[200010];
int main() {
  int n, q;
  cin >> n >> q;
  r[0] = r[n + 1] = q;
  x[q] = 0;
  y[q] = 0;
  while (q--) {
    char c;
    cin >> x[q] >> y[q] >> c;
    map<int, int>::iterator it = r.lower_bound(x[q]);
    if (it->first == x[q]) {
      puts("0");
      continue;
    }
    r[x[q]] = q;
    if (c == 'U') {
      printf("%d\n", y[q] - y[it->second]);
      y[q] = y[it->second];
    } else {
      it--;
      it--;
      printf("%d\n", x[q] - x[it->second]);
      x[q] = x[it->second];
    }
  }
}
