#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
set<std::pair<int, int> > st;
set<std::pair<int, int> >::iterator it;
int n, m, x[M], y[M];
char str[2];
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++) {
    scanf("%d%d%s", x + i, y + i, str);
    bool ok = *str == 'U';
    if (ok)
      it = st.lower_bound(make_pair(x[i], 0));
    else
      it = st.upper_bound(make_pair(x[i], m + 1)), it--;
    if (x[i] == it->first) {
      puts("0");
      continue;
    }
    st.insert(make_pair(x[i], i));
    int j = it->second;
    if (ok) {
      printf("%d\n", y[i] - y[j]);
      y[i] = y[j];
    } else {
      printf("%d\n", x[i] - x[j]);
      x[i] = x[j];
    }
  }
  return 0;
}
