#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
int add(int a, int b) {
  if ((a += b) >= P) a -= P;
  return a;
}
int sub(int a, int b) {
  if ((a -= b) < 0) a += P;
  return a;
}
int mul(int a, int b) { return 1ll * a * b % P; }
int kpow(int a, int b) {
  int r = 1;
  for (; b; b >>= 1, a = mul(a, a)) {
    if (b & 1) r = mul(r, a);
  }
  return r;
}
const int N = 202020;
int n, m;
vector<int> V;
struct Q {
  int x, y;
  char o;
} q[N];
int find(int x) { return lower_bound(V.begin(), V.end(), x) - V.begin() + 1; }
struct Seg {
  static const int N = ::N << 3;
  int ma[N];
  void upd(int L, int R, int c, int l, int r, int rt) {
    if (L <= l && r <= R) {
      ma[rt] = max(ma[rt], c);
      return;
    }
    int mid = l + r >> 1;
    if (L <= mid) upd(L, R, c, l, mid, rt << 1);
    if (R >= mid + 1) upd(L, R, c, mid + 1, r, rt << 1 | 1);
  }
  int qry(int p, int l, int r, int rt) {
    if (l == r) return ma[rt];
    int mid = l + r >> 1, ans = ma[rt];
    if (p <= mid)
      ans = max(ans, qry(p, l, mid, rt << 1));
    else
      ans = max(ans, qry(p, mid + 1, r, rt << 1 | 1));
    return ans;
  }
} t1, t2;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> n >> m;
  for (int i = (1); i < (m + 1); i++) {
    string s;
    cin >> q[i].x >> q[i].y >> s;
    q[i].o = s[0];
    V.push_back(q[i].x);
    V.push_back(q[i].y);
  }
  V.push_back(0);
  sort(V.begin(), V.end());
  V.erase(unique(V.begin(), V.end()), V.end());
  map<pair<int, int>, bool> vis;
  for (int i = (1); i < (m + 1); i++) {
    int x = q[i].x, y = q[i].y;
    int px = find(x), py = find(y);
    char o = q[i].o;
    if (vis[make_pair(x, y)]) {
      cout << 0 << "\n";
      continue;
    }
    vis[make_pair(x, y)] = 1;
    if (o == 'L') {
      int t = t2.qry(py, 1, (int)V.size(), 1);
      cout << x - t << "\n";
      int pt = find(t);
      t1.upd(pt + 1, px, y, 1, (int)V.size(), 1);
    } else {
      int t = t1.qry(px, 1, (int)V.size(), 1);
      cout << y - t << "\n";
      int pt = find(t);
      t2.upd(pt + 1, py, x, 1, (int)V.size(), 1);
    }
  }
  return 0;
}
