#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int oo = 1e9 + 5;
struct seg {
  seg(int a, int x, int y) : A(a), first(x), second(y) {}
  int A;
  int first;
  int second;
};
bool operator<(const seg &M, const seg &N) { return M.A < N.A; }
set<seg> segs;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int N, Q;
  scanf("%d %d\n", &N, &Q);
  segs.insert(seg(0, 0, 0));
  for (int i = 0; i < Q; ++i) {
    int x, y;
    char c;
    scanf("%d %d %c\n", &x, &y, &c);
    set<seg>::iterator it = segs.upper_bound(seg(x, 0, 0));
    --it;
    if (x == it->A) {
      printf("0\n");
      continue;
    }
    int fa = it->A;
    int fy = it->second;
    int fx = it->first;
    if (c == 'U') {
      printf("%d\n", y - it->second);
      segs.insert(seg(x, x, fy));
    } else {
      printf("%d\n", x - it->first);
      segs.erase(it);
      segs.insert(seg(fa, fx, y));
      segs.insert(seg(x, fx, fy));
    }
  }
  return 0;
}
