#include <bits/stdc++.h>
using namespace std;
bool exitInput = false;
int ntest = 1, itest = 1;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {1, -1, 0, 0};
const char* directions[4] = {"NE", "SE", "SW", "NW"};
const long long Mod = 1000000000LL + 7;
const int maxn = 200000 + 5;
const int maxv = 2000 + 5;
const int maxe = 9000 + 5;
int n, q, x[maxn], y[maxn], d[maxn], rx[maxn], ry[maxn];
vector<int> rrhx, rrhy;
map<int, int> realx, realy;
bool visit[maxn][2];
int itx[4 * maxn + 4], ity[4 * maxn + 4], lazyx[4 * maxn + 4],
    lazyy[4 * maxn + 4];
void build_it(int it[], int node, int l, int r) {
  if (l == r) {
    it[node] = 0;
    return;
  }
  build_it(it, (node << 1), l, ((l + r) >> 1));
  build_it(it, ((node << 1) | 1), ((l + r) >> 1) + 1, r);
}
void lazy_update(int lazy[], int it[], int node, int l, int r) {
  it[node] = max(it[node], lazy[node]);
  if (l != r) {
    lazy[(node << 1)] = max(lazy[(node << 1)], lazy[node]);
    lazy[((node << 1) | 1)] = max(lazy[((node << 1) | 1)], lazy[node]);
  }
  lazy[node] = 0;
}
void update(int lazy[], int it[], int node, int l, int r, int i, int j,
            int val) {
  lazy_update(lazy, it, node, l, r);
  if (r < i || j < l) {
    return;
  }
  if (i <= l && r <= j) {
    it[node] = max(it[node], val);
    if (l != r) {
      lazy[(node << 1)] = max(lazy[(node << 1)], val);
      lazy[((node << 1) | 1)] = max(lazy[((node << 1) | 1)], val);
    }
    return;
  }
  update(lazy, it, (node << 1), l, ((l + r) >> 1), i, j, val);
  update(lazy, it, ((node << 1) | 1), ((l + r) >> 1) + 1, r, i, j, val);
}
int query(int lazy[], int it[], int node, int l, int r, int i) {
  lazy_update(lazy, it, node, l, r);
  if (r < i || i < l) {
    return -1;
  }
  if (l == r && r == i) {
    return it[node];
  }
  int p1 = query(lazy, it, (node << 1), l, ((l + r) >> 1), i);
  int p2 = query(lazy, it, ((node << 1) | 1), ((l + r) >> 1) + 1, r, i);
  return max(p1, p2);
}
int main() {
  int i, j, k;
  scanf("%d %d", &n, &q);
  char s[3];
  for (i = 0; i < q; ++i) {
    scanf("%d %d %s", &x[i], &y[i], s);
    if (s[0] == 'L')
      d[i] = 0;
    else
      d[i] = 1;
    rrhx.push_back(x[i]);
    rrhy.push_back(y[i]);
  }
  sort((rrhx).begin(), (rrhx).end());
  sort((rrhy).begin(), (rrhy).end());
  realx[0] = 0;
  realy[0] = 0;
  for (i = 0; i < q; ++i) {
    k = 1 + lower_bound((rrhx).begin(), (rrhx).end(), x[i]) - rrhx.begin();
    rx[i] = x[i];
    realx[k] = x[i];
    x[i] = k;
    k = 1 + lower_bound((rrhy).begin(), (rrhy).end(), y[i]) - rrhy.begin();
    realy[k] = y[i];
    ry[i] = y[i];
    y[i] = k;
  }
  int L, R;
  for (i = 0; i < q; ++i) {
    if ((d[i] == 1 && visit[x[i]][d[i]]) || (d[i] == 0 && visit[y[i]][d[i]])) {
      printf("0\n");
    } else if (d[i] == 0) {
      visit[y[i]][d[i]] = true;
      j = query(lazyy, ity, 1, 1, maxn - 5, y[i]);
      printf("%d\n", rx[i] - j);
      L = 1 + lower_bound((rrhx).begin(), (rrhx).end(), j + 1) - rrhx.begin();
      R = 1 + upper_bound((rrhx).begin(), (rrhx).end(), rx[i]) - rrhx.begin();
      --R;
      update(lazyx, itx, 1, 1, maxn - 5, L, R, ry[i]);
    } else {
      visit[x[i]][d[i]] = true;
      j = query(lazyx, itx, 1, 1, maxn - 5, x[i]);
      printf("%d\n", ry[i] - j);
      L = 1 + lower_bound((rrhy).begin(), (rrhy).end(), j + 1) - rrhy.begin();
      R = 1 + upper_bound((rrhy).begin(), (rrhy).end(), ry[i]) - rrhy.begin();
      --R;
      update(lazyy, ity, 1, 1, maxn - 5, L, R, rx[i]);
    }
  }
  return 0;
}
