#include <bits/stdc++.h>
using namespace std;
struct node {
  node *r, *l;
  int v;
  node() {
    l = NULL;
    r = NULL;
    v = 0;
  }
};
inline void update(node*& cur, int b, int e, int l, int r, int val);
inline int query(node*& cur, int b, int e, int id);
constexpr int MAXN = 1 << 30;
node* root[2];
int n, q;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> q;
  while (q--) {
    int v[2];
    char a;
    cin >> v[0] >> v[1] >> a;
    bool rel = (a == 'L');
    bool relax = rel ^ 1;
    int ans = query(root[rel], 0, MAXN, v[rel]);
    cout << v[relax] - ans << '\n';
    update(root[relax], 0, MAXN, ans + 1, v[relax] + 1, v[rel]);
    update(root[rel], 0, MAXN, v[rel], v[rel] + 1, v[relax]);
  }
}
inline void update(node*& cur, int b, int e, int l, int r, int val) {
  if (b >= r || e <= l) return;
  if (cur == NULL) cur = new node();
  if (l <= b && r >= e) {
    cur->v = max(cur->v, val);
  } else {
    int mid = (b + e) >> 1;
    update(cur->l, b, mid, l, r, val);
    update(cur->r, mid, e, l, r, val);
  }
}
inline int query(node*& cur, int b, int e, int id) {
  if (cur == NULL) return 0;
  if (b == e - 1)
    return cur->v;
  else {
    int mid = (b + e) >> 1;
    if (mid > id)
      return max(cur->v, query(cur->l, b, mid, id));
    else
      return max(cur->v, query(cur->r, mid, e, id));
  }
}
