#include <bits/stdc++.h>
using namespace std;
int n, m;
struct wen {
  int x, y, opt;
} a[400005];
int u[400005];
struct aa {
  int l, r, x;
} c[400005 << 2], d[400005 << 2];
void jianshu(aa *c, int i, int l, int r) {
  int mid = (l + r) >> 1;
  c[i].l = l;
  c[i].r = r;
  if (l == r) {
    return;
  }
  jianshu(c, (i << 1), l, mid);
  jianshu(c, ((i << 1) | 1), mid + 1, r);
}
namespace lsh {
map<int, int> p;
int t[400005], f[400005];
void QAQ() {
  int nn = 0;
  for (int i = 1; i <= m; i++) {
    nn++;
    t[nn] = a[i].x;
    nn++;
    t[nn] = a[i].y;
  }
  sort(t + 1, t + nn + 1);
  for (int i = 1; i <= nn; i++)
    if (t[i] == t[i - 1])
      f[i] = f[i - 1];
    else
      f[i] = f[i - 1] + 1;
  for (int i = 1; i <= nn; i++) {
    p[t[i]] = f[i];
    u[f[i]] = t[i];
  }
  n = f[nn];
  int i = 1;
  for (i = 1; i <= m; i++) {
    a[i].x = p[a[i].x];
    a[i].y = p[a[i].y];
  }
}
}  // namespace lsh
void rd() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    string opt;
    scanf("%d%d", &x, &y);
    cin >> opt;
    a[i].x = x;
    a[i].y = y;
    if (opt == "U")
      a[i].opt = 1;
    else
      a[i].opt = 2;
  }
  lsh::QAQ();
}
void gai(aa *c, int i, int l, int r, int x) {
  if (l <= c[i].l && c[i].r <= r) {
    c[i].x = max(c[i].x, x);
    return;
  }
  if (l > c[i].r || r < c[i].l) return;
  gai(c, (i << 1), l, r, x);
  gai(c, ((i << 1) | 1), l, r, x);
}
int qiu(aa *c, int i, int l) {
  if (c[i].l == c[i].r) return c[i].x;
  int mid = (c[i].l + c[i].r) >> 1;
  if (l > mid)
    return max(c[i].x, qiu(c, ((i << 1) | 1), l));
  else
    return max(c[i].x, qiu(c, (i << 1), l));
}
int main() {
  rd();
  jianshu(c, 1, 1, n);
  jianshu(d, 1, 1, n);
  for (int i = 1; i <= m; i++) {
    if (a[i].opt == 1) {
      int p = qiu(d, 1, a[i].x);
      printf("%d\n", u[a[i].y] - u[p]);
      gai(c, 1, p + 1, a[i].y, a[i].x);
      gai(d, 1, a[i].x, a[i].x, a[i].y);
    } else {
      int p = qiu(c, 1, a[i].y);
      printf("%d\n", u[a[i].x] - u[p]);
      gai(d, 1, p + 1, a[i].x, a[i].y);
      gai(c, 1, a[i].y, a[i].y, a[i].x);
    }
  }
  return 0;
}
