#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T sqr(T t) {
  return t * t;
}
inline void files() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int n, q, t[5000100], L[5000100], R[5000100], lst, lst1, t1[5000100],
    L1[5000100], R1[5000100];
int ob[5000100], ob1[5000100];
inline void push(int v) {
  if (ob[v] == 0) return;
  if (L[v] == 0) L[v] = ++lst;
  if (R[v] == 0) R[v] = ++lst;
  t[L[v]] = max(t[L[v]], ob[v]);
  t[R[v]] = max(t[R[v]], ob[v]);
  ob[L[v]] = max(ob[L[v]], ob[v]);
  ob[R[v]] = max(ob[R[v]], ob[v]);
  ob[v] = 0;
}
inline void push1(int v) {
  if (ob1[v] == 0) return;
  if (L1[v] == 0) L1[v] = ++lst1;
  if (R1[v] == 0) R1[v] = ++lst1;
  t1[L1[v]] = max(t1[L1[v]], ob1[v]);
  t1[R1[v]] = max(t1[R1[v]], ob1[v]);
  ob1[L1[v]] = max(ob1[L1[v]], ob1[v]);
  ob1[R1[v]] = max(ob1[R1[v]], ob1[v]);
  ob1[v] = 0;
}
void update(int v, int l, int r, int tl, int tr, int num) {
  if (l > r || tl > r || l > tr) return;
  if (tl <= l && r <= tr) {
    t[v] = max(t[v], num);
    ob[v] = max(ob[v], num);
    return;
  }
  push(v);
  int mid = (l + r) >> 1;
  if (L[v] == 0) L[v] = ++lst;
  update(L[v], l, mid, tl, tr, num);
  if (R[v] == 0) R[v] = ++lst;
  update(R[v], mid + 1, r, tl, tr, num);
}
void update1(int v, int l, int r, int tl, int tr, int num) {
  if (l > r || tl > r || l > tr) return;
  if (tl <= l && r <= tr) {
    t1[v] = max(num, t1[v]);
    ob1[v] = max(ob1[v], num);
    return;
  }
  push1(v);
  int mid = (l + r) >> 1;
  if (L1[v] == 0) L1[v] = ++lst1;
  update1(L1[v], l, mid, tl, tr, num);
  if (R1[v] == 0) R1[v] = ++lst1;
  update1(R1[v], mid + 1, r, tl, tr, num);
}
int get(int v, int l, int r, int pos) {
  if (l == r && l == pos) return t[v];
  push(v);
  int mid = (l + r) >> 1;
  if (pos <= mid) {
    if (L[v] == 0) L[v] = ++lst;
    return get(L[v], l, mid, pos);
  } else {
    if (R[v] == 0) R[v] = ++lst;
    return get(R[v], mid + 1, r, pos);
  }
}
int get1(int v, int l, int r, int pos) {
  if (l == r && l == pos) return t1[v];
  push1(v);
  int mid = (l + r) >> 1;
  if (pos <= mid) {
    if (L1[v] == 0) L1[v] = ++lst1;
    return get1(L1[v], l, mid, pos);
  } else {
    if (R1[v] == 0) R1[v] = ++lst1;
    return get1(R1[v], mid + 1, r, pos);
  }
}
int main() {
  files();
  lst = 1;
  lst1 = 1;
  cin >> n >> q;
  for (int i = 1; i <= q; i++) {
    int x, y;
    char u;
    cin >> x >> y >> u;
    if (u == 'L') {
      int ans = get(1, 1, n, y);
      cout << x - ans << "\n";
      update1(1, 1, n, ans + 1, x, y);
      update(1, 1, n, y, y, x);
    } else {
      int ans = get1(1, 1, n, x);
      cout << y - ans << "\n";
      update(1, 1, n, ans + 1, y, x);
      update1(1, 1, n, x, x, y);
    }
  }
}
