#include <bits/stdc++.h>
using namespace std;
int gi() {
  int a;
  scanf("%d", &a);
  return a;
}
long long gli() {
  long long a;
  scanf("%lld", &a);
  return a;
}
struct bar_ {
  int a;
  int b;
  int left;
  int top;
};
map<int, bar_> m;
map<int, bar_>::iterator it;
void ins(bar_ &b) {
  if (b.a <= b.b) m[b.b] = b;
}
int main() {
  int n = gi();
  int q = gi();
  bar_ bar = {1, n, 1, n};
  bar_ b1, b2;
  ins(bar);
  for (int i = 0; i < q; i++) {
    int x = gi();
    int dummy = gi();
    char c;
    scanf(" %c", &c);
    it = m.lower_bound(x);
    if (it == m.end() || (bar = it->second).a > x) {
      printf("0\n");
      continue;
    }
    m.erase(it);
    b1 = bar;
    b2 = bar;
    b1.b = x - 1;
    b2.a = x + 1;
    if (c == 'U') {
      printf("%d\n", bar.top - x + 1);
      b2.left = x + 1;
    } else {
      printf("%d\n", x - bar.left + 1);
      b1.top = x - 1;
    }
    ins(b1);
    ins(b2);
  }
  return 0;
}
