#include <bits/stdc++.h>
using namespace std;
const int MAX = 4e5 + 9;
int n, q, tree[2][4 * MAX], lazy[2][4 * MAX], l, r, idx, val;
vector<pair<pair<int, int>, char> > v;
map<int, int> encode, decode;
void push(int id, int low, int high, int pos) {
  tree[id][pos] = max(tree[id][pos], lazy[id][pos]);
  if (low != high) {
    lazy[id][(pos << 1)] = max(lazy[id][(pos << 1)], lazy[id][pos]);
    lazy[id][(pos << 1) + 1] = max(lazy[id][(pos << 1) + 1], lazy[id][pos]);
  }
}
void upd(int id, int low, int high, int pos) {
  push(id, low, high, pos);
  if (l > high || r < low) {
    return;
  }
  if (l <= low && r >= high) {
    lazy[id][pos] = max(lazy[id][pos], val);
    return;
  }
  int mid = ((low + high) >> 1);
  upd(id, low, mid, (pos << 1));
  upd(id, mid + 1, high, (pos << 1) + 1);
  tree[id][pos] = max(tree[id][(pos << 1)], tree[id][(pos << 1) + 1]);
}
int qwr(int id, int low, int high, int pos) {
  push(id, low, high, pos);
  if (low == high) {
    return tree[id][pos];
  }
  int mid = ((low + high) >> 1);
  if (idx <= mid) {
    return qwr(id, low, mid, (pos << 1));
  } else {
    return qwr(id, mid + 1, high, (pos << 1) + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> q;
  for (int i = 1; i <= q; ++i) {
    int x, y;
    char type;
    cin >> x >> y >> type;
    encode[x];
    encode[y];
    v.push_back({{x, y}, type});
  }
  int cnt = 0;
  for (auto& element : encode) {
    element.second = ++cnt;
    decode[cnt] = element.first;
  }
  for (int i = 0; i < q; ++i) {
    int newX = encode[v[i].first.first], newY = encode[v[i].first.second];
    char type = v[i].second;
    if (type == 'L') {
      idx = newY;
      int lastX = qwr(1, 1, (q << 1), 1);
      cout << decode[newX] - decode[lastX] << "\n";
      l = lastX + 1;
      r = newX;
      val = newY;
      upd(0, 1, (q << 1), 1);
      l = newY;
      r = newY, val = newX;
      upd(1, 1, (q << 1), 1);
    } else {
      idx = newX;
      int lastY = qwr(0, 1, (q << 1), 1);
      cout << decode[newY] - decode[lastY] << "\n";
      l = lastY + 1;
      r = newY;
      val = newX;
      upd(1, 1, (q << 1), 1);
      l = newX;
      r = newX, val = newY;
      upd(0, 1, (q << 1), 1);
    }
  }
  return 0;
}
