#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000,100000000000")
using namespace std;
const double eps = 1E-9;
const double Exp = 2.718281828459045;
const double Pi = 3.1415926535897932;
const int NMAX = 200000 + 5;
const int MMAX = 100000 + 5;
const int INF = 1000000000;
const int BS = 1000000007;
template <typename T>
inline T abs(const T a) {
  if (a < 0) return -a;
  return a;
}
template <typename T>
inline T sqr(const T& a) {
  return a * a;
}
int _left[NMAX];
int top[NMAX];
int cs = 0;
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  int n, q;
  cin >> n >> q;
  int x, y;
  char c;
  set<pair<int, int> > st;
  _left[cs] = 0;
  top[cs] = 0;
  st.insert(make_pair(0, cs++));
  st.insert(make_pair(n + 1, -1));
  set<pair<int, int> >::iterator it, it2;
  while (q--) {
    cin >> x >> y >> c;
    it = (--st.upper_bound(make_pair(x, INF)));
    if (it->first == x) {
      cout << 0 << endl;
      continue;
    }
    if (c == 'U') {
      cout << y - top[it->second] << endl;
      st.insert(make_pair(x, cs));
      _left[cs] = x;
      top[cs] = top[it->second];
      cs++;
    } else {
      cout << x - _left[it->second] << endl;
      st.insert(make_pair(x, cs));
      _left[cs] = _left[it->second];
      top[cs] = top[it->second];
      top[it->second] = y;
      cs++;
    }
  }
  return 0;
}
