#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 5;
struct SegmentTree {
  int lazy[maxn];
  int maxv[maxn];
  void set_lazy(int o, int value) {
    lazy[o] = max(lazy[o], value);
    maxv[o] = max(maxv[o], lazy[o]);
  }
  void push_down(int o) {
    lazy[o * 2] = max(lazy[o * 2], lazy[o]);
    maxv[o * 2] = max(lazy[o * 2], maxv[o * 2]);
    lazy[o * 2 + 1] = max(lazy[o * 2 + 1], lazy[o]);
    maxv[o * 2 + 1] = max(lazy[o * 2 + 1], maxv[o * 2 + 1]);
  }
  void maintain(int o) {
    maxv[o] = max(maxv[o], max(maxv[o * 2], maxv[o * 2 + 1]));
  }
  void update(int o, int l, int r, int x, int y, int value) {
    if (x <= l && r <= y) {
      set_lazy(o, value);
    } else {
      push_down(o);
      int m = (l + r) / 2;
      if (x <= m && y >= l) update(o * 2, l, m, x, y, value);
      if (y >= m + 1 && x <= r) update(o * 2 + 1, m + 1, r, x, y, value);
      maintain(o);
    }
  }
  int query(int o, int l, int r, int p) {
    if (l == r) {
      return maxv[o];
    } else {
      push_down(o);
      int ans = 0;
      int m = (l + r) / 2;
      if (p <= m) ans = max(ans, query(o * 2, l, m, p));
      if (p >= m + 1) ans = max(ans, query(o * 2 + 1, m + 1, r, p));
      return ans;
    }
  }
};
struct Query {
  int a, b;
  char c;
  Query(int a, int b, char c) : a(a), b(b), c(c) {}
};
vector<Query> querys;
vector<int> nums;
int N, M;
SegmentTree trees[2];
map<int, int> mapn;
map<int, bool> vis;
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= M; i++) {
    int a, b;
    char c;
    scanf("%d%d %c", &a, &b, &c);
    querys.push_back(Query(a, b, c));
    nums.push_back(a);
    nums.push_back(a + 1);
    nums.push_back(b);
    nums.push_back(b + 1);
  }
  sort(nums.begin(), nums.end());
  mapn[nums[0]] = 1;
  for (int i = 1, len = nums.size(); i < len; i++)
    if (nums[i] != nums[i - 1]) mapn[nums[i]] = mapn[nums[i - 1]] + 1;
  N = mapn[nums[nums.size() - 1]];
  for (int i = 0, len = querys.size(); i < len; i++) {
    int a = querys[i].a, b = querys[i].b;
    if (vis[a]) {
      printf("0\n");
      continue;
    }
    vis[a] = true;
    char c = querys[i].c;
    if (c == 'U') {
      int ca = mapn[a];
      int up = trees[1].query(1, 1, N, ca);
      printf("%d\n", b - up);
      trees[0].update(1, 1, N, mapn[up + 1], mapn[b], a);
    } else {
      int cb = mapn[b];
      int up = trees[0].query(1, 1, N, cb);
      printf("%d\n", a - up);
      trees[1].update(1, 1, N, mapn[up + 1], mapn[a], b);
    }
  }
  return 0;
}
