#include <bits/stdc++.h>
using namespace std;
map<int, int> dictx, dicty;
int ulimit[800100], llimit[800100], nseg, nk, flag[200100], ord[200100],
    x[200100], mode[200100], srt[200100], n;
bool comp(int a, int b) { return x[a] < x[b]; }
void update(int *seg, int l, int r, int x, int n, int v) {
  if (x * n >= l && x * n + n - 1 <= r)
    seg[x] = max(seg[x], v);
  else if (x * n <= r && x * n + n - 1 >= l) {
    update(seg, l, r, x * 2, n / 2, v);
    update(seg, l, r, x * 2 + 1, n / 2, v);
  }
}
int query(int *seg, int x) {
  int mi = 0;
  while (x > 0) {
    mi = max(seg[x], mi);
    x /= 2;
  }
  return mi;
}
int main() {
  int cal, t, siz, i, j, k;
  char str[10];
  scanf("%d %d", &siz, &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &x[i], &t);
    scanf("%s", &str);
    if (str[0] == 'U')
      mode[i] = 0;
    else
      mode[i] = 1;
    srt[i] = i;
  }
  sort(srt, srt + n, comp);
  k = 0;
  for (i = 0; i < n; i++) {
    flag[k] = 0;
    ord[srt[i]] = k;
    if (x[srt[i]] != x[srt[i + 1]]) {
      dictx[x[srt[i]]] = k;
      dicty[siz + 1 - x[srt[i]]] = k;
      k++;
    }
  }
  nk = k + 1;
  dictx[0] = 0;
  dicty[0] = nk;
  nseg = 1;
  while (nseg < nk * 2) nseg *= 2;
  for (i = 0; i < nseg; i++) {
    ulimit[i] = 0;
    llimit[i] = 0;
  }
  for (i = 0; i < n; i++) {
    if (flag[ord[i]] == 1)
      printf("0\n");
    else if (mode[i] == 0) {
      flag[ord[i]] = 1;
      cal = query(ulimit, ord[i] + nseg / 2);
      printf("%d\n", (siz + 1 - x[i]) - cal);
      update(llimit, ord[i] + nseg / 2, dicty[cal] + nseg / 2, 1, nseg / 2,
             x[i]);
    } else {
      flag[ord[i]] = 1;
      cal = query(llimit, ord[i] + nseg / 2);
      printf("%d\n", x[i] - cal);
      update(ulimit, dictx[cal] + nseg / 2, ord[i] + nseg / 2, 1, nseg / 2,
             siz + 1 - x[i]);
    }
  }
  return 0;
}
