#include <bits/stdc++.h>
using namespace std;
const double EPS = -1e8;
const double Pi = acos(-1);
bool inline equ(double a, double b) { return fabs(a - b) < EPS; }
const int MAXN = 200010;
int n, q;
set<tuple<int, int, int> > bst;
int qryl(int x, int y) {
  auto it = bst.lower_bound(make_tuple(x, -1, -1));
  if (it == bst.end()) return y;
  int tx, tl, typ;
  tie(tx, tl, typ) = *it;
  assert(x <= tx);
  if (tx == x) return 0;
  if (typ == 1)
    return tx - x;
  else
    return tl + tx - x;
}
int qryu(int x, int y) {
  auto it = bst.upper_bound(make_tuple(x, 1100000000, 1100000000));
  if (it == bst.begin()) return x;
  it--;
  int tx, tl, typ;
  tie(tx, tl, typ) = *it;
  assert(tx <= x);
  if (tx == x) return 0;
  if (typ == 0)
    return x - tx;
  else
    return tl + x - tx;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  while (q--) {
    int x, y;
    char typ[2];
    cin >> y >> x >> typ;
    if (typ[0] == 'L') {
      int res = qryl(x, y);
      cout << res << '\n';
      if (res) bst.insert(make_tuple(x, res, 0));
    } else {
      int res = qryu(x, y);
      cout << res << '\n';
      if (res) bst.insert(make_tuple(x, res, 1));
    }
  }
}
