#include <bits/stdc++.h>
using namespace std;
struct node {
  int r, c;
  int last;
  char ty;
  node() {}
  node(int a, int b, int cc, char t) {
    r = a;
    c = b;
    last = cc;
    ty = t;
  }
  bool operator<(const node& b) const { return r < b.r; }
  bool operator==(const node& b) const { return r == b.r && c == b.c; }
};
int cmp(node a, node b) { return a.r > b.r; }
set<node> sb;
set<node>::iterator it;
int main() {
  int i, j;
  int n, m;
  int a, b;
  char op;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    node tp;
    scanf("%d %d %c", &a, &b, &op);
    if (op == 'U') {
      tp.r = a;
      it = sb.lower_bound(tp);
      if (it->r == a) {
        printf("0\n");
      } else if (it == sb.end()) {
        sb.insert(node(a, b, 1, op));
        printf("%d\n", b);
      } else {
        if (it->ty == 'U') {
          sb.insert(node(a, b, it->last, op));
          printf("%d\n", b - it->last + 1);
        } else {
          sb.insert(node(a, b, it->c + 1, op));
          printf("%d\n", b - it->c);
        }
      }
    } else {
      tp.r = a;
      it = sb.lower_bound(tp);
      if (it->r == a) {
        printf("0\n");
      } else if (it == sb.begin()) {
        sb.insert(node(a, b, 1, op));
        printf("%d\n", a);
      } else {
        it--;
        if (it->ty == 'L') {
          sb.insert(node(a, b, it->last, op));
          printf("%d\n", a - it->last + 1);
        } else {
          sb.insert(node(a, b, it->r + 1, op));
          printf("%d\n", a - it->r);
        }
      }
    }
  }
  return 0;
}
