#include <bits/stdc++.h>
using namespace std;
int n, m;
map<int, pair<bool, int> > mp;
int main() {
  scanf("%d%d", &n, &m);
  mp.insert(make_pair(n + 1, make_pair(0, n + 1)));
  mp.insert(make_pair(0, make_pair(1, n + 1)));
  int x, y;
  bool q;
  char ch[2];
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%s", &x, &y, ch);
    q = ch[0] == 'U';
    int res;
    if (q) {
      map<int, pair<bool, int> >::iterator it = mp.lower_bound(x);
      if (it->first == x)
        res = 0;
      else if (it->second.first)
        res = it->first + it->second.second - x;
      else
        res = it->first - x;
    } else {
      map<int, pair<bool, int> >::iterator it = mp.upper_bound(x);
      --it;
      if (it->first == x)
        res = 0;
      else if (it->second.first)
        res = x - it->first;
      else
        res = x - it->first + it->second.second;
    }
    printf("%d\n", res);
    mp.insert(make_pair(x, make_pair(q, res)));
  }
  return 0;
}
