#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const int MOD = 1000000007;
const int TN = 400109;
struct tree {
  int mx[TN * 4 + 1];
  void upd(int v, int l, int r, int from, int to, int nv) {
    if (from > to || from > r || l > to) return;
    if (l == from && r == to) {
      mx[v] = max(mx[v], nv);
      return;
    }
    int mid = (l + r) / 2;
    upd(2 * v, l, mid, from, min(mid, to), nv);
    upd(2 * v + 1, mid + 1, r, max(mid + 1, from), to, nv);
  }
  int getmax(int v, int l, int r, int pos) {
    if (l == r) return mx[v];
    int v2;
    int mid = (l + r) / 2;
    if (pos <= mid)
      v2 = getmax(2 * v, l, mid, pos);
    else
      v2 = getmax(2 * v + 1, mid + 1, r, pos);
    return max(mx[v], v2);
  }
};
const int N = 200009;
int x[N + 1], y[N + 1];
char c[N + 1];
tree T1, T2;
int main() {
  int n, q;
  cin >> n >> q;
  set<int> xx, yy;
  for (int i = (1); i <= (q); ++i) {
    scanf("%d %d %c", &y[i], &x[i], &c[i]);
    for (int dx = (0); dx <= (1); ++dx)
      xx.insert(x[i] + dx), yy.insert(y[i] + dx);
  }
  xx.insert(0);
  xx.insert(1);
  yy.insert(0);
  yy.insert(1);
  map<int, int> mem_x;
  int sz_x = 0;
  for (set<int>::iterator it = xx.begin(); it != xx.end(); ++it)
    mem_x[*it] = ++sz_x;
  map<int, int> mem_y;
  int sz_y = 0;
  for (set<int>::iterator it = yy.begin(); it != yy.end(); ++it)
    mem_y[*it] = ++sz_y;
  set<pair<int, int> > eat;
  for (int i = (1); i <= (q); ++i) {
    int ans;
    if (eat.count(make_pair(x[i], y[i])))
      ans = 0;
    else if (c[i] == 'L') {
      int mx = T2.getmax(1, 1, sz_x, mem_x[x[i]]);
      ans = y[i] - mx;
      T1.upd(1, 1, sz_y, mem_y[mx + 1], mem_y[y[i]], x[i]);
    } else if (c[i] == 'U') {
      int mx = T1.getmax(1, 1, sz_y, mem_y[y[i]]);
      ans = x[i] - mx;
      T2.upd(1, 1, sz_x, mem_x[mx + 1], mem_x[x[i]], y[i]);
    }
    eat.insert(make_pair(x[i], y[i]));
    printf("%d\n", ans);
  }
}
