#include <bits/stdc++.h>
using namespace std;
int n, Q;
struct polje {
  int x, y, id;
  char sgn;
};
polje p[200007];
int cmp1(polje A, polje B) { return A.x < B.x; }
int cmp2(polje A, polje B) { return A.y < B.y; }
int cmp3(polje A, polje B) { return A.id < B.id; }
struct Tree {
  int t[4 * 200007];
  int lazy[4 * 200007];
  void push_down(int node, int l, int r) {
    if (lazy[node]) {
      t[node] = max(t[node], lazy[node]);
      if (l < r) {
        lazy[2 * node] = max(lazy[2 * node], lazy[node]);
        lazy[2 * node + 1] = max(lazy[2 * node + 1], lazy[node]);
      }
      lazy[node] = 0;
    }
  }
  void update(int node, int st, int en, int l, int r, int val) {
    push_down(node, st, en);
    if (st > en || l > en || r < st) return;
    if (l <= st && en <= r) {
      lazy[node] = max(lazy[node], val);
      push_down(node, st, en);
      return;
    }
    int mid = (st + en) / 2;
    update(2 * node, st, mid, l, r, val);
    update(2 * node + 1, mid + 1, en, l, r, val);
    t[node] = max(t[2 * node], t[2 * node + 1]);
  }
  int get(int node, int st, int en, int l, int r) {
    push_down(node, st, en);
    if (st > en || l > en || r < st) return -1000000007;
    if (l <= st && en <= r) return t[node];
    int mid = (st + en) / 2;
    int T1 = get(2 * node, st, mid, l, r);
    int T2 = get(2 * node + 1, mid + 1, en, l, r);
    return max(T1, T2);
  }
} Tv, Th;
map<int, int> hsh;
map<pair<int, int>, int> BIO;
int izvorx[200007], izvory[200007];
int main() {
  ios_base::sync_with_stdio(0);
  scanf("%d%d", &n, &Q);
  for (int i = 1; i <= Q; i++) {
    scanf("%d %d %c", &p[i].x, &p[i].y, &p[i].sgn);
    p[i].id = i;
  }
  int idi1 = 0;
  sort(p + 1, p + Q + 1, cmp1);
  for (int i = 1; i <= Q; i++) {
    if (!hsh[p[i].x]) hsh[p[i].x] = ++idi1;
    izvorx[hsh[p[i].x]] = p[i].x;
    p[i].x = hsh[p[i].x];
  }
  sort(p + 1, p + Q + 1, cmp3);
  sort(p + 1, p + Q + 1, cmp2);
  hsh.clear();
  int idi2 = 0;
  for (int i = 1; i <= Q; i++) {
    if (!hsh[p[i].y]) hsh[p[i].y] = ++idi2;
    izvory[hsh[p[i].y]] = p[i].y;
    p[i].y = hsh[p[i].y];
  }
  sort(p + 1, p + Q + 1, cmp3);
  for (int i = 1; i <= Q; i++) {
    if (BIO[{p[i].x, p[i].y}]) {
      printf("0\n");
      continue;
    }
    BIO[{p[i].x, p[i].y}] = 1;
    if (p[i].sgn == 'U') {
      int max_gore = Tv.get(1, 1, Q + 280, p[i].x, p[i].x);
      Tv.update(1, 1, Q + 280, p[i].x, p[i].x, izvory[p[i].y]);
      int res = izvory[p[i].y] - max_gore;
      int gore =
          upper_bound(izvory + 1, izvory + idi2 + 1, max_gore) - (izvory + 1);
      Th.update(1, 1, Q + 280, gore, p[i].y, izvorx[p[i].x]);
      printf("%d\n", res);
    } else {
      int max_levo = Th.get(1, 1, Q + 280, p[i].y, p[i].y);
      Th.update(1, 1, Q + 280, p[i].y, p[i].y, izvorx[p[i].x]);
      int res = izvorx[p[i].x] - max_levo;
      int levo =
          upper_bound(izvorx + 1, izvorx + idi1 + 1, max_levo) - (izvorx + 1);
      Tv.update(1, 1, Q + 280, levo, p[i].x, izvory[p[i].y]);
      printf("%d\n", res);
    }
  }
  return 0;
}
