#include <bits/stdc++.h>
using namespace std;
inline long double min(long double a, long double b) {
  if (a < b) return a;
  return b;
}
inline long double max(long double a, long double b) {
  if (a < b) return b;
  return a;
}
int n, q;
int x[200010];
int y[200010];
map<int, int> m;
unordered_set<int> uset;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  char c;
  x[q] = y[q] = 0;
  m[0] = q;
  m[n + 1] = q;
  for (int(i) = (0); (i) < (q); ++(i)) {
    cin >> x[i] >> y[i] >> c;
    if (uset.count(x[i])) {
      cout << 0 << endl;
      continue;
    }
    uset.insert(x[i]);
    auto j = m.lower_bound(x[i]);
    m[x[i]] = i;
    if (c == 'U') {
      int index = j->second;
      int val = y[i] - y[index];
      y[i] = y[index];
      cout << val << endl;
    } else {
      j--;
      j--;
      int index = j->second;
      int val = x[i] - x[index];
      x[i] = x[index];
      cout << val << endl;
    }
  }
  return 0;
}
