#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
int n, m;
struct R {
  int x1, y1, x2, y2;
  R() {}
  R(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};
bool operator<(const R& a, const R& b) {
  return max(a.x1, a.y1) < max(b.x1, b.y1);
}
char buf[2];
int main() {
  scanf("%d%d", &n, &m);
  set<R> S;
  S.insert(R(1, 1, n, n));
  while (m-- > 0) {
    int x, y;
    scanf("%d%d", &x, &y);
    y = n - y + 1;
    scanf("%s", buf);
    set<R>::iterator it = S.upper_bound(R(x, y, x, y));
    if (it == S.begin()) {
      printf("0\n");
      continue;
    }
    it--;
    if (it->y2 < y || it->x2 < x) {
      printf("0\n");
      continue;
    }
    R r = *it;
    S.erase(r);
    if (buf[0] == 'L') {
      printf("%d\n", x - r.x1 + 1);
      if (r.y1 != y) S.insert(R(r.x1, r.y1, r.x2, y - 1));
      if (r.y2 != y) S.insert(R(r.x1, y + 1, r.x2, r.y2));
    } else {
      printf("%d\n", r.y2 - y + 1);
      if (r.x1 != x) S.insert(R(r.x1, r.y1, x - 1, r.y2));
      if (r.x2 != x) S.insert(R(x + 1, r.y1, r.x2, r.y2));
    }
  }
  return 0;
}
