#include <bits/stdc++.h>
using namespace std;
int a;
int answer(int l, int r, int b, int e, int i, const vector<int>& x) {
  if ((l == b) && (r == e)) return x[i];
  int m = (e + b) / 2;
  if (m <= l) return max(x[i], answer(l, r, m, e, i * 2 + 2, x));
  if (m >= r) return max(x[i], answer(l, r, b, m, i * 2 + 1, x));
  return max(x[i], max(answer(l, m, b, m, i * 2 + 1, x),
                       answer(m, r, m, e, i * 2 + 2, x)));
}
void mod(int l, int r, int b, int e, int i, vector<int>& x, int s) {
  if ((l == b) && (r == e)) {
    x[i] = max(x[i], s);
    return;
  }
  int m = (e + b) / 2;
  if (m <= l) {
    return mod(l, r, m, e, i * 2 + 2, x, s);
  }
  if (m >= r) {
    return mod(l, r, b, m, i * 2 + 1, x, s);
  }
  mod(l, m, b, m, i * 2 + 1, x, s);
  mod(m, r, m, e, i * 2 + 2, x, s);
  return;
}
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  vector<pair<int, char> > z(m);
  vector<int> x(m), y(m);
  for (int i = 0; i < m; i++) {
    cin >> x[i];
    z[i].first = x[i];
    cin >> y[i];
    cin >> z[i].second;
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  map<int, int> xx, yy, zz;
  for (int i = 0; i < m; i++) {
    xx[x[i]] = i;
    yy[y[i]] = i;
    x[i] = y[i] = 0;
  }
  vector<int> sx(4 * m, 0), sy(4 * m, 0);
  int s, p, k;
  for (int i = 0; i < m; i++) {
    if (zz[z[i].first] == -1) {
      cout << 0 << endl;
      continue;
    }
    if (z[i].second == 'U') {
      s = z[i].first;
      p = s = n + 1 - z[i].first;
      s = yy[s];
      s = answer(s, s + 1, 0, m, 0, sy);
      cout << p - s << endl;
      if (s == 0)
        k = m;
      else {
        k = xx[n + 1 - s] + 1;
      }
      if (k != xx[z[i].first] + 1)
        mod(xx[z[i].first] + 1, k, 0, m, 0, sx, z[i].first);
    } else {
      p = s = z[i].first;
      s = xx[s];
      s = answer(s, s + 1, 0, m, 0, sx);
      cout << p - s << endl;
      if (s == 0)
        k = m;
      else {
        k = yy[n + 1 - s] + 1;
      }
      if (k != yy[n + 1 - p] + 1)
        mod(yy[n + 1 - p] + 1, k, 0, m, 0, sy, n + 1 - z[i].first);
    }
    zz[z[i].first] = -1;
  }
  return 0;
}
