#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
typedef struct Query {
  int x, md;
  Query(int x = 0, int md = 0) : x(x), md(md) {}
} Query;
Query Q[maxn];
int bdes1[maxn], bdes2[maxn], n, q, c;
map<int, int> mp1, mp2;
map<int, int>::iterator it;
typedef struct BiT {
  int t[maxn * 3];
  int lazy[maxn * 3];
  void clear() {
    memset(t, 0, sizeof(t));
    memset(lazy, -1, sizeof(lazy));
  }
  void build(int l, int r, int x) {
    if (l == r) {
      t[x] = 0;
      return;
    }
    int m = (l + r) / 2;
    build(l, m, x << 1);
    build(m + 1, r, x << 1 | 1);
  }
  void update(int L, int R, int a, int l, int r, int x) {
    if (L == l && R == r) {
      lazy[x] = max(lazy[x], a);
      t[x] = max(a, t[x]);
      return;
    }
    pushdown(l, r, x);
    int m = (l + r) / 2;
    if (L > m)
      update(L, R, a, m + 1, r, x << 1 | 1);
    else if (R <= m)
      update(L, R, a, l, m, x << 1);
    else {
      update(L, m, a, l, m, x << 1);
      update(m + 1, R, a, m + 1, r, x << 1 | 1);
    }
  }
  void pushdown(int l, int r, int x) {
    if (lazy[x] != -1) {
      lazy[x << 1] = max(lazy[x << 1], lazy[x]);
      lazy[x << 1 | 1] = max(lazy[x << 1 | 1], lazy[x]);
      t[x << 1] = max(t[x << 1], lazy[x]);
      t[x << 1 | 1] = max(t[x << 1 | 1], lazy[x]);
      lazy[x] = -1;
    }
  }
  int get(int p, int l, int r, int x) {
    if (l == r) {
      return t[x];
    }
    int m = (l + r) / 2;
    pushdown(l, r, x);
    if (p > m)
      return get(p, m + 1, r, x << 1 | 1);
    else
      return get(p, l, m, x << 1);
  }
} BiT;
BiT T1, T2;
int m1, m2;
void des() {
  for (int i = 0; i < q; i++) {
    mp1[Q[i].x] = 0;
    mp2[n + 1 - Q[i].x] = 0;
  }
  c = 0;
  mp1[0] = 0;
  mp2[0] = 0;
  for (it = mp1.begin(); it != mp1.end(); it++) {
    (*it).second = c;
    bdes1[c++] = (*it).first;
  }
  c = 0;
  for (it = mp2.begin(); it != mp2.end(); it++) {
    (*it).second = c;
    bdes2[c++] = (*it).first;
  }
  m1 = mp1.size();
  m2 = mp2.size();
}
void input() {
  cin >> n >> q;
  char md;
  int b;
  for (int i = 0; i < q; i++) {
    scanf("%d%d %c", &Q[i].x, &b, &md);
    if (md == 'U')
      Q[i].md = 0;
    else
      Q[i].md = 1;
  }
  des();
}
bool v1[maxn] = {0}, v2[maxn] = {0};
int main() {
  input();
  T1.clear();
  T2.clear();
  T1.build(1, m1, 1);
  T2.build(1, m2, 1);
  for (int i = 0; i < q; i++) {
    if (!Q[i].md) {
      int u = mp1[Q[i].x], len;
      if (v1[u]) {
        cout << 0 << endl;
        continue;
      }
      len = T1.get(u, 1, m1, 1);
      cout << n + 1 - Q[i].x - bdes2[len] << endl;
      if (n + 1 - Q[i].x - bdes2[len])
        T2.update(len + 1, mp2[n + 1 - Q[i].x], u, 1, m2, 1);
      v1[u] = 1;
    } else {
      int u = mp2[n + 1 - Q[i].x], len;
      if (v2[u]) {
        cout << 0 << endl;
        continue;
      }
      len = T2.get(u, 1, m2, 1);
      cout << Q[i].x - bdes1[len] << endl;
      if (Q[i].x - bdes1[len]) T1.update(len + 1, mp1[Q[i].x], u, 1, m1, 1);
      v2[u] = 1;
    }
  }
  return 0;
}
