#include <bits/stdc++.h>
using namespace std;
struct segtree {
  int i, j;
  int minvalue;
  int pvalue;
  segtree *l, *r;
  segtree(vector<int> &v, int I, int J) : pvalue(-1), l(NULL), r(NULL) {
    i = v[I];
    j = v[J];
    minvalue = 0;
    if (I == J) {
    } else {
      int K = I + J >> 1;
      l = new segtree(v, I, K);
      r = new segtree(v, K + 1, J);
    }
  }
  void visit() {
    if (minvalue < pvalue) {
      minvalue = pvalue;
      if (l) {
        l->pvalue = max(l->pvalue, pvalue);
        r->pvalue = max(r->pvalue, pvalue);
      }
    }
    pvalue = -1;
  }
  void setmx(int I, int J, int v) {
    if (I <= i && j <= J) {
      pvalue = max(pvalue, v);
      visit();
    } else {
      visit();
      if (!(j < I || J < i)) {
        l->setmx(I, J, v);
        r->setmx(I, J, v);
        minvalue = min(l->minvalue, r->minvalue);
      }
    }
  }
  int get(int I) {
    visit();
    if (i == j) {
      return minvalue;
    } else if (l->i <= I && I <= l->j) {
      return l->get(I);
    } else {
      return r->get(I);
    }
  }
  void prstate() {
    printf("[%d %d]:", i, j);
    printf("%d (%d)", minvalue, pvalue);
    printf("\n");
    if (l) l->prstate();
    if (r) r->prstate();
  }
};
struct qr {
  int x, y;
  bool left;
};
qr qrs[201111];
vector<int> xs;
vector<int> ys;
char s[111];
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = (0); i < (q); i++) {
    int x, y;
    scanf("%d%d%s", &x, &y, s);
    xs.push_back(x);
    ys.push_back(y);
    qrs[i].x = x;
    qrs[i].y = y;
    qrs[i].left = *s == 'L';
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());
  xs.resize(distance(xs.begin(), unique(xs.begin(), xs.end())));
  ys.resize(distance(ys.begin(), unique(ys.begin(), ys.end())));
  segtree *tops = new segtree(xs, 0, xs.size() - 1);
  segtree *lefts = new segtree(ys, 0, ys.size() - 1);
  for (int i = (0); i < (q); i++) {
    int x = qrs[i].x;
    int y = qrs[i].y;
    int ans;
    if (qrs[i].left) {
      int X = lefts->get(y);
      lefts->setmx(y, y, x);
      if (X < x) tops->setmx(X + 1, x, y);
      ans = x - X;
    } else {
      int Y = tops->get(x);
      tops->setmx(x, x, y);
      if (Y < y) lefts->setmx(Y + 1, y, x);
      ans = y - Y;
    }
    printf("%d\n", ans);
  }
}
