#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
int x[N + 2], y[N + 2], t[N + 2];
int main() {
  int n, q;
  cin >> n >> q;
  set<pair<int, int> > s;
  t[q] = 1;
  x[q] = 0;
  s.insert(make_pair(0, q));
  t[q + 1] = 0;
  y[q + 1] = 0;
  s.insert(make_pair(n + 1, q + 1));
  for (int i = 0; i < q; ++i) {
    char buffer[2];
    scanf("%d%d%s", x + i, y + i, buffer);
    t[i] = *buffer == 'U';
    set<pair<int, int> >::iterator it;
    if (t[i] == 0) {
      it = s.upper_bound(make_pair(x[i], INT_MAX));
      it--;
    } else {
      it = s.lower_bound(make_pair(x[i], INT_MIN));
    }
    int j = it->second;
    if (x[i] == it->first) {
      puts("0");
    } else {
      s.insert(make_pair(x[i], i));
      int x0 = x[i];
      int y0 = y[i];
      if (t[i] == 0) {
        x[i] = x[j];
      } else {
        y[i] = y[j];
      }
      printf("%d\n", x0 - x[i] + y0 - y[i]);
    }
  }
  return 0;
}
