#include <bits/stdc++.h>
using namespace std;
long long lazy[800200 * 4][2], seg[800200 * 4][2];
void updLazy(int node, int ini, int fim, int k) {
  if (lazy[node][k] == 0) return;
  seg[node][k] = max(seg[node][k], lazy[node][k]);
  if (ini != fim) {
    lazy[node * 2][k] = max(lazy[node * 2][k], lazy[node][k]);
    lazy[node * 2 + 1][k] = max(lazy[node * 2 + 1][k], lazy[node][k]);
  }
  lazy[node][k] = 0;
}
void update(int node, int ini, int fim, int x, int y, long long val, int k) {
  updLazy(node, ini, fim, k);
  if (ini > y || fim < x) return;
  if (ini >= x && fim <= y) {
    lazy[node][k] = max(lazy[node][k], val);
    updLazy(node, ini, fim, k);
  } else {
    int fe = node * 2, fd = fe + 1, mid = (ini + fim) / 2;
    update(fe, ini, mid, x, y, val, k);
    update(fd, mid + 1, fim, x, y, val, k);
    seg[node][k] = max(seg[fe][k], seg[fd][k]);
  }
}
long long query(int node, int ini, int fim, int x, int y, int k) {
  updLazy(node, ini, fim, k);
  if (ini > y || fim < x) return 0;
  if (ini >= x && fim <= y) return seg[node][k];
  int fe = node * 2, fd = fe + 1, mid = (ini + fim) / 2;
  return max(query(fe, ini, mid, x, y, k), query(fd, mid + 1, fim, x, y, k));
}
int n, q;
int a[800200], b[800200];
char c[800200];
map<int, int> mapa, rmapa;
vector<int> v;
void compress() {
  v.push_back(n);
  v.push_back(1);
  for (int i = 0; i < q; i++) {
    v.push_back(a[i]);
    v.push_back(b[i]);
    v.push_back(a[i] + 1);
    v.push_back(b[i] + 1);
  }
  sort((v).begin(), (v).end());
  int cnt = 1;
  for (int i = 0; i < ((int)(v).size()); i++) {
    if (i == 0 || v[i] != v[i - 1]) {
      mapa[v[i]] = cnt;
      rmapa[cnt] = v[i];
      cnt++;
    }
  }
  n = mapa[n];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> q;
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  compress();
  update(1, 1, n, 1, n, 1, 0);
  update(1, 1, n, 1, n, 1, 1);
  for (int i = 0; i < q; i++) {
    int x, y;
    char d;
    x = mapa[a[i]];
    y = mapa[b[i]];
    d = c[i];
    swap(x, y);
    int limite;
    if (d == 'U') {
      limite = query(1, 1, n, y, y, 0);
      update(1, 1, n, y, y, x + 1, 0);
      update(1, 1, n, limite, x, y + 1, 1);
      cout << rmapa[x] - rmapa[limite] + 1 << endl;
    } else {
      limite = query(1, 1, n, x, x, 1);
      update(1, 1, n, x, x, y + 1, 1);
      update(1, 1, n, limite, y, x + 1, 0);
      cout << rmapa[y] - rmapa[limite] + 1 << endl;
    }
  }
}
