#include <bits/stdc++.h>
using namespace std;
int read() {
  int w = 0, f = 1;
  char c = ' ';
  while (c < '0' || c > '9') c = getchar(), f = c == '-' ? -1 : f;
  while (c >= '0' && c <= '9') w = w * 10 + c - 48, c = getchar();
  return w * f;
}
int readop() {
  char c = getchar();
  while (c != 'U' && c != 'L') c = getchar();
  return c == 'U';
}
struct node {
  int x, y, op;
} q[200005];
struct seg {
  int ls[200005 << 2], rs[200005 << 2], tag[200005 << 2];
  void update(int p, int x, int y, int v, int l, int r) {
    if (x <= l && r <= y) return tag[p] = max(tag[p], v), void();
    int mid = (l + r) >> 1;
    if (x <= mid) update(p << 1, x, y, v, l, mid);
    if (y > mid) update(p << 1 | 1, x, y, v, mid + 1, r);
  }
  int query(int p, int x, int l, int r) {
    if (l == r) return tag[p];
    int mid = (l + r) >> 1;
    if (x <= mid) return max(tag[p], query(p << 1, x, l, mid));
    return max(tag[p], query(p << 1 | 1, x, mid + 1, r));
  }
} s1, s2;
bool vis[200005];
int n, m, w[200005], cnt;
int work1(int x, int y) {
  if (vis[x]) return 0;
  vis[x] = 1;
  int v = s1.query(1, x, 1, cnt);
  s2.update(1, v + 1, y, x, 1, cnt);
  return w[cnt - v + 1] - w[x];
}
int work2(int x, int y) {
  if (vis[x]) return 0;
  vis[x] = 1;
  int v = s2.query(1, y, 1, cnt);
  s1.update(1, v + 1, x, y, 1, cnt);
  return w[x] - w[v];
}
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++)
    q[i].x = read(), q[i].y = read(), q[i].op = readop(), w[i] = q[i].x;
  sort(w + 1, w + m + 1);
  cnt = unique(w + 1, w + m + 1) - w - 1;
  for (int i = 1; i <= m; i++)
    q[i].x = lower_bound(w + 1, w + cnt + 1, q[i].x) - w,
    q[i].y = cnt - q[i].x + 1;
  w[cnt + 1] = n + 1;
  for (int i = 1; i <= m; i++) {
    printf("%d\n", q[i].op ? work1(q[i].x, q[i].y) : work2(q[i].x, q[i].y));
  }
  return 0;
}
