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