#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
int l[400200], r[400200], x1[400200], x2[400200], p[400200], du[400200],
    dl[400200];
bool in(char c) {
  if (c == 'U' || c == 'L') return true;
  return false;
}
int split(int t1, int t2) {
  if (t1 == 0) return t2;
  if (t2 == 0) return t1;
  if (p[t1] > p[t2]) {
    r[t1] = split(r[t1], t2);
    return t1;
  }
  l[t2] = split(t1, l[t2]);
  return t2;
}
bool find(int t, int xx) {
  if (t == 0) return false;
  if (x1[t] <= xx && x2[t] >= xx) return true;
  if (x1[t] > xx) return find(l[t], xx);
  if (x2[t] < xx) return find(r[t], xx);
}
vector<int> merge(int t, int xx) {
  vector<int> ans(3, 0);
  if (t == 0) return ans;
  if (x2[t] < xx) {
    vector<int> p;
    p = merge(r[t], xx);
    r[t] = p[0];
    ans[0] = t;
    ans[1] = p[1];
    ans[2] = p[2];
    return ans;
  }
  if (x1[t] > xx) {
    vector<int> p;
    p = merge(l[t], xx);
    l[t] = p[2];
    ans[0] = p[0];
    ans[1] = p[1];
    ans[2] = t;
    return ans;
  }
  ans[0] = l[t];
  ans[1] = t;
  ans[2] = r[t];
  l[t] = 0;
  r[t] = 0;
  return ans;
}
void solve(int n, int k) {
  int i, j, m, q, z, x = 2;
  vector<int> w;
  int ans = 0, ll, rr;
  for (i = 0; i < 400200; i++) {
    p[i] = rand() ^ (rand() << 16);
    l[i] = 0;
    r[i] = 0;
    du[i] = 0;
    dl[i] = 0;
  }
  q = 1;
  x1[1] = 1;
  x2[1] = n;
  char c;
  for (i = 0; i < k; i++) {
    scanf("%d%d", &ll, &rr);
    while (!in(c = getchar()))
      ;
    if (find(q, ll)) {
      w = merge(q, ll);
      if (c == 'U') {
        ans = x2[w[1]] - ll + 1 + du[w[1]];
        if (ll > x1[w[1]]) {
          x1[x] = x1[w[1]];
          x2[x] = ll - 1;
          du[x] = du[w[1]] + x2[w[1]] - ll + 1;
          dl[x] = dl[w[1]];
          dl[w[1]] = 0;
          x1[w[1]] = ll + 1;
          if (x1[w[1]] <= x2[w[1]]) w[2] = split(w[1], w[2]);
          q = split(split(w[0], x), w[2]);
          x++;
        } else {
          x1[w[1]] = ll + 1;
          dl[w[1]] = 0;
          if (x1[w[1]] <= x2[w[1]]) w[2] = split(w[1], w[2]);
          q = split(w[0], w[2]);
        }
      } else {
        ans = ll - x1[w[1]] + 1 + dl[w[1]];
        if (ll < x2[w[1]]) {
          x1[x] = ll + 1;
          x2[x] = x2[w[1]];
          dl[x] = dl[w[1]] + (ll - x1[w[1]] + 1);
          du[x] = du[w[1]];
          x2[w[1]] = ll - 1;
          du[w[1]] = 0;
          if (x1[w[1]] <= x2[w[1]]) w[0] = split(w[0], w[1]);
          q = split(w[0], split(x, w[2]));
          x++;
        } else {
          x2[w[1]] = ll - 1;
          du[w[1]] = 0;
          if (x1[w[1]] <= x2[w[1]]) w[2] = split(w[1], w[2]);
          q = split(w[0], w[2]);
        }
      }
      printf("%d\n", ans);
    } else {
      printf("0\n");
    }
  }
  printf("\n");
}
int main() {
#pragma comment(linker, "/STACK:1073741824")
  int n, m, k, i;
  while (scanf("%d%d", &n, &k) != EOF) {
    solve(n, k);
  }
  return 0;
}
