#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b;
char c;
set<pair<int, int> > st;
set<pair<int, int> >::iterator it;
int x[200005], y[200005];
int main() {
  cin >> n >> m;
  int i;
  st.insert(make_pair(0, 0));
  st.insert(make_pair(n + 1, m + 1));
  for (i = 1; i <= m; i++) {
    cin >> y[i] >> x[i];
    getchar();
    cin >> c;
    if (c == 'U') {
      it = st.lower_bound(make_pair(x[i], -1));
      if (it->first > x[i]) it--;
    } else
      it = st.upper_bound(make_pair(x[i], -1));
    if (it->first == x[i]) {
      puts("0");
      continue;
    }
    st.insert(make_pair(x[i], i));
    if (c == 'U') {
      printf("%d\n", x[i] - x[it->second]);
      x[i] = x[it->second];
    } else {
      printf("%d\n", y[i] - y[it->second]);
      y[i] = y[it->second];
    }
  }
  return 0;
}
