#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, up, left;
  node(int x, int up, int left) {
    this->x = x;
    this->up = up;
    this->left = left;
  }
  bool operator<(const node &cmp) const { return x < cmp.x; }
};
set<node> a;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  a.insert(node(0, 0, 0));
  for (int i = 1; i <= q; i++) {
    int x, y;
    char s[5];
    scanf("%d%d%s", &x, &y, s);
    set<node>::iterator p = a.upper_bound(node(x, 0, 0));
    p--;
    int px = p->x, pup = p->up, pleft = p->left;
    if (px == x) {
      printf("0\n");
      continue;
    }
    if (s[0] == 'U') {
      printf("%d\n", y - pup);
      a.insert(node(x, pup, x));
    }
    if (s[0] == 'L') {
      printf("%d\n", x - pleft);
      a.erase(p);
      a.insert(node(px, y, pleft));
      a.insert(node(x, pup, pleft));
    }
  }
  return 0;
}
