#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 333;
const long long linf = 1e18 + 333;
const int N = 2e5 + 555;
int n, q, a[N], b[N], t[2][N << 1];
map<pair<int, int>, bool> M;
char c[N];
vector<int> row, col;
int get(bool w, int x) {
  int ans = 0;
  for (x += N; x; x >>= 1) ans = max(ans, t[w][x]);
  return ans;
}
void up(bool w, int l, int r, int k) {
  l += N;
  r += N;
  t[w][l] = max(t[w][l], k);
  t[w][r] = max(t[w][r], k);
  for (; l <= r; l >>= 1, r >>= 1) {
    if (l & 1) {
      t[w][l] = max(t[w][l], k);
      l++;
    }
    if (~r & 1) {
      t[w][r] = max(t[w][r], k);
      r--;
    }
  }
}
int main() {
  ios ::sync_with_stdio(0);
  cin >> n >> q;
  row.push_back(1);
  col.push_back(1);
  for (int i = 1; i <= q; i++) {
    cin >> a[i] >> b[i] >> c[i];
    row.push_back(b[i]);
    col.push_back(a[i]);
  }
  sort(row.begin(), row.end());
  sort(col.begin(), col.end());
  row.resize(unique(row.begin(), row.end()) - row.begin());
  col.resize(unique(col.begin(), col.end()) - col.begin());
  for (int i = 1; i <= q; i++) {
    if (M[pair<int, int>(a[i], b[i])]) {
      cout << 0 << endl;
      continue;
    }
    M[pair<int, int>(a[i], b[i])] = 1;
    int x = lower_bound(col.begin(), col.end(), a[i]) - col.begin();
    int y = lower_bound(row.begin(), row.end(), b[i]) - row.begin();
    if (c[i] == 'U') {
      int go = get(0, x) + 1;
      int wgo = lower_bound(row.begin(), row.end(), go) - row.begin();
      cout << b[i] - go + 1 << endl;
      up(1, wgo, y, a[i]);
    } else {
      int go = get(1, y) + 1;
      int wgo = lower_bound(col.begin(), col.end(), go) - col.begin();
      cout << a[i] - go + 1 << endl;
      up(0, wgo, x, b[i]);
    }
  }
  return 0;
}
