#include <bits/stdc++.h>
using namespace std;
const int INF = 1011110000;
vector<int> ke;
int n, m;
struct Point {
  int x, y;
  char c;
  Point(int _x = 0, int _y = 0, char _c = 0) : x(_x), y(_y), c(_c) {}
} pt[201111];
struct SegT {
  int n, num[3201111];
  void init(int _n) {
    n = _n;
    fill(num, num + 4 * n, 0);
  }
  void maxi(int l, int r, int x) { maxi(l, r, x, 0, n, 0); }
  int find(int i) { return find(i, 0, n, 0); }
  void maxi(int l, int r, int x, int tl, int tr, int id) {
    int md = (tr + tl) / 2;
    if (r <= tl || tr <= l) return;
    push(tl, tr, id);
    if (l <= tl && tr <= r) {
      num[id] = max(x, num[id]);
      return;
    }
    maxi(l, r, x, tl, md, id * 2 + 1);
    maxi(l, r, x, md, tr, id * 2 + 2);
  }
  int find(int i, int tl, int tr, int id) {
    int md = (tr + tl) / 2;
    push(tl, tr, id);
    if (tr - tl == 1) return num[id];
    if (i < md)
      return find(i, tl, md, id * 2 + 1);
    else
      return find(i, md, tr, id * 2 + 2);
  }
  void push(int tl, int tr, int id) {
    if (tl - tr == 1) return;
    num[id * 2 + 1] = max(num[id * 2 + 1], num[id]);
    num[id * 2 + 2] = max(num[id * 2 + 2], num[id]);
  }
} stx, sty;
inline int ker(int x) {
  return lower_bound(ke.begin(), ke.end(), x) - ke.begin();
}
void input() {
  scanf("%d%d", &n, &m);
  ke.clear();
  for (int i = 0; i < m; i++) {
    cin >> pt[i].x >> pt[i].y >> pt[i].c;
    ke.push_back(pt[i].x);
    ke.push_back(pt[i].y);
  }
  ke.push_back(0);
  sort(ke.begin(), ke.end());
  ke.resize(unique(ke.begin(), ke.end()) - ke.begin());
}
void solve() {
  bool vst[401111];
  memset(vst, 0, sizeof(vst));
  stx.init(ke.size());
  sty.init(ke.size());
  for (int i = 0; i < m; i++) {
    int x = pt[i].x, y = pt[i].y;
    if (vst[ker(x)]) {
      printf("0\n");
      continue;
    }
    vst[ker(x)] = 1;
    swap(x, y);
    if (pt[i].c == 'U') {
      printf("%d\n", x - sty.find(ker(y)));
      stx.maxi(ker(sty.find(ker(y))), ker(x) + 1, y);
    } else {
      printf("%d\n", y - stx.find(ker(x)));
      sty.maxi(ker(stx.find(ker(x))), ker(y) + 1, x);
    }
  }
}
int main() {
  int t = 1;
  while (t--) {
    input();
    solve();
  }
}
