#include <bits/stdc++.h>
using namespace std;
int n, q, x, y, hor, ver;
char z;
set<pair<int, pair<int, int> > > S;
set<pair<int, pair<int, int> > >::iterator it;
set<int> B;
int main() {
  scanf("%d%d", &n, &q);
  S.insert(make_pair(0, make_pair(0, 0)));
  while (q--) {
    scanf("%d%d", &y, &x);
    cin >> z;
    if (B.find(y) != B.end()) {
      printf("0\n");
      continue;
    }
    B.insert(y);
    it = S.upper_bound(make_pair(-y, make_pair(0, 0)));
    if (it != S.end()) {
      hor = it->second.first;
      ver = it->second.second;
      if (z == 'U') {
        S.insert(make_pair(-y, make_pair(hor, y)));
        printf("%d\n", x - hor);
      } else {
        S.insert(make_pair(-y, make_pair(hor, ver)));
        printf("%d\n", y - ver);
        S.insert(make_pair(it->first, make_pair(x, it->second.second)));
        S.erase(it);
      }
    } else
      assert(0);
  }
  return 0;
}
