#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:67108864")
using namespace std;
const int MX = 200005;
const int MOD = 1000000007;
set<int> L, U;
struct node {
  node(int nw) : nw(nw) { left = right = NULL; }
  int nw;
  node *left, *right;
};
struct segtree {
  node* root;
  int S = 0, E = 1000000000;
  segtree() { root = new node(-1); }
  void insert(int s, int e, int nw) { return insert(root, S, E, s, e, nw); }
  void insert(node* n, int s, int e, int l, int r, int nw) {
    if (e < l || r < s)
      return;
    else if (l <= s && e <= r) {
      n->nw = max(nw, n->nw);
    } else {
      int m = (s + e) / 2;
      if (!n->left) n->left = new node(n->nw), n->right = new node(n->nw);
      insert(n->left, s, m, l, r, nw);
      insert(n->right, m + 1, e, l, r, nw);
    }
  }
  int read(int ad) { return read(root, S, E, ad); }
  int read(node* n, int s, int e, int ad) {
    if (!n) return -1;
    int m = (s + e) / 2;
    if (ad <= m)
      return max(n->nw, read(n->left, s, m, ad));
    else
      return max(n->nw, read(n->right, m + 1, e, ad));
  }
} T[2];
set<int> chk;
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  T[0].insert(1, N, 0);
  T[1].insert(1, N, 0);
  for (int i = 1; i <= Q; i++) {
    int X, Y;
    char ord[10];
    scanf("%d%d%s", &X, &Y, ord);
    if (chk.find(X) != chk.end())
      printf("0\n");
    else if (ord[0] == 'U') {
      int ans = T[1].read(X);
      printf("%d\n", Y - ans);
      T[0].insert(ans, Y, X);
    } else {
      int ans = T[0].read(Y);
      printf("%d\n", X - ans);
      T[1].insert(ans, X, Y);
    }
    chk.insert(X);
  }
  return 0;
}
