#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
using namespace std;
using mt = int32_t;
using fl = double;
template <typename T>
constexpr mt infValue = std::numeric_limits<T>::max() - 1000;
template <typename T>
constexpr mt maxValue =
    std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;
constexpr mt INF = infValue<mt>;
constexpr int64_t MOD = 1000000007ll;
constexpr double EPS = 1e-6;
constexpr mt MAX = maxValue<mt>;
using pr = pair<mt, mt>;
constexpr auto N = 2000001;
constexpr auto K = 6;
constexpr auto P = 19;
constexpr auto M = 200111;
struct tree {
  mt l = -1;
  mt r = -1;
  mt val = 0;
} * s;
mt nextIdx;
mt lineTop = -1, columnTop = -1;
void apply(mt &v, mt val = 0) {
  if (v == -1) v = nextIdx++;
  s[v].val = max(val, s[v].val);
}
void push(mt v) {
  if (s[v].val != -1) {
    apply(s[v].l, s[v].val);
    apply(s[v].r, s[v].val);
    s[v].val = -1;
  }
}
mt get(mt &v, mt tl, mt tr, mt pos) {
  if (v == -1) return 0;
  if ((pos > (tl + tr >> 1) && s[v].r == -1) || s[v].l == -1) return s[v].val;
  apply(v);
  if (tl == tr) return s[v].val;
  push(v);
  mt md = tl + tr >> 1;
  if (pos > md) return get(s[v].r, md + 1, tr, pos);
  return get(s[v].l, tl, md, pos);
}
void update(mt &v, mt tl, mt tr, mt l, mt r, mt val) {
  apply(v);
  if (l > r) return;
  if (tl != tr) push(v);
  if (tl == l && tr == r) {
    s[v].val = max(s[v].val, val);
    return;
  }
  mt md = tl + tr >> 1;
  update(s[v].l, tl, md, l, min(md, r), val);
  update(s[v].r, md + 1, tr, max(md + 1, l), r, val);
}
mt n, q;
int main(void) {
  scanf("%d %d", &n, &q);
  s = new tree[N * 8];
  while (q--) {
    mt l, r;
    char t;
    scanf("%d %d %c\n", &r, &l, &t);
    if (t == 'L') {
      mt idx = get(lineTop, 1, n, l);
      printf("%d\n", r - idx);
      update(columnTop, 1, n, idx + 1, r, l);
      update(lineTop, 1, n, l, l, r);
    } else {
      mt idx = get(columnTop, 1, n, r);
      printf("%d\n", l - idx);
      update(lineTop, 1, n, idx + 1, l, r);
      update(columnTop, 1, n, r, r, l);
    }
  }
  return 0;
}
