#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
int x[N], y[N];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  s.insert(make_pair(n + 1, m + 1));
  s.insert(make_pair(0, 0));
  for (int i = 1; i <= m; i++) {
    char c[5];
    scanf("%d%d%s", &x[i], &y[i], c);
    if (c[0] == 'U') {
      it = s.lower_bound(make_pair(y[i], -1));
      if (it->first > y[i]) it--;
    } else {
      it = s.upper_bound(make_pair(y[i], -1));
    }
    if (it->first == y[i]) {
      printf("0\n");
      continue;
    }
    s.insert(make_pair(y[i], i));
    if (c[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;
}
