#include <bits/stdc++.h>
using namespace std;
int const M = 202020;
long long const mod = 1000000007LL;
map<int, int> mpu, mpl, mpu2, mpl2;
int idu, idl, idu2, idl2;
int getUId(int x) {
  if (mpu.find(x) == mpu.end()) mpu[x] = idu++;
  return mpu[x];
}
int getUId2(int x) {
  if (mpu2.find(x) == mpu2.end()) mpu2[x] = idu2++;
  return mpu2[x];
}
int l[M], r[M];
set<int> su, sl;
set<int> ssu, ssl;
set<int> mark;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  sl.insert(n + 1);
  su.insert(n + 2);
  ssu.insert(n + 1);
  ssl.insert(n + 2);
  int x, y;
  char ch[5];
  int ans;
  for (int i = 0; i < (q); ++i) {
    scanf(" %d %d %s", &x, &y, ch);
    if (mark.find(x) != mark.end()) {
      puts("0");
      continue;
    }
    mark.insert(x);
    int ty = n + 1 - y;
    int tx = n + 1 - x;
    if (ch[0] == 'U') {
      int nu = *su.lower_bound(ty);
      int uid = getUId(nu);
      int nl = *sl.lower_bound(ty);
      int lid = getUId(nl);
      int id = getUId(ty);
      if (nl < nu) {
        ans = nl - ty;
        l[id] = nl;
      } else {
        ans = l[uid] - ty;
        l[id] = l[uid];
      }
      su.insert(ty);
      ssu.insert(tx);
    } else if (ch[0] == 'L') {
      int nu = *ssu.lower_bound(tx);
      int uid = getUId2(nu);
      int nl = *ssl.lower_bound(tx);
      int lid = getUId2(nl);
      int id = getUId2(tx);
      if (nu < nl) {
        ans = nu - tx;
        r[id] = nu;
      } else {
        ans = r[lid] - tx;
        r[id] = r[lid];
      }
      sl.insert(ty);
      ssl.insert(tx);
    }
    printf("%d\n", ans);
  }
  return 0;
}
