#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int INF = 1 << 30;
const int N = 200000 + 10;
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
int x[N], y[N];
int main() {
  int n, q;
  char d[2];
  scanf("%d%d", &n, &q);
  s.insert(make_pair(0, q + 1));
  s.insert(make_pair(n + 1, q + 1));
  x[0] = y[0] = 0;
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d%s", &x[i], &y[i], d);
    if (d[0] == 'U') {
      it = s.lower_bound(make_pair(x[i], -1));
    } else {
      it = s.upper_bound(make_pair(x[i], q + 1));
      it--;
    }
    int first = it->first;
    if (it->first == x[i]) {
      printf("0\n");
      continue;
    }
    s.insert(make_pair(x[i], i));
    int idx = it->second;
    if (d[0] == 'U') {
      printf("%d\n", y[i] - y[it->second]);
      y[i] = y[it->second];
    } else {
      printf("%d\n", x[i] - x[it->second]);
      x[i] = x[it->second];
    }
  }
  return 0;
}
