#include <bits/stdc++.h>
using namespace std;
struct Node {
  Node(int s = 0, Node* left = nullptr, Node* right = nullptr)
      : val(s), L(left), R(right), lazy(s) {}
  Node* L;
  Node* R;
  int val;
  int lazy;
};
struct DynamicSegmentTree {
  DynamicSegmentTree(int sz) : n(sz) { root = fetchNode(); }
  void upd(int left, int right, int v) {
    l = left;
    r = right;
    val = v;
    upd(root, 0, n);
  }
  int qwr(int left, int right) {
    l = left;
    r = right;
    return qwr(root, 0, n);
  }
  void push(Node* T) {
    if (T->L != nullptr) T->L->lazy = max(T->L->lazy, T->lazy);
    if (T->R != nullptr) T->R->lazy = max(T->R->lazy, T->lazy);
    T->val = max(T->val, T->lazy);
  }
  void merge(Node* T) {
    if (T->L != nullptr) T->val = max(T->val, T->L->val);
    if (T->R != nullptr) T->val = max(T->val, T->R->val);
  }
  void upd(Node* T, int low, int high) {
    if (l > high || r < low) {
      return;
    }
    if (l <= low && r >= high) {
      T->lazy = max(T->lazy, val);
      push(T);
      return;
    }
    int mid = ((low + high) >> 1);
    if (T->L != nullptr) push(T->L);
    if (T->R != nullptr) push(T->R);
    if (T->L == nullptr) {
      T->L = fetchNode(T->lazy);
    }
    if (l <= mid) {
      upd(T->L, low, mid);
    }
    if (T->R == nullptr) {
      T->R = fetchNode(T->lazy);
    }
    if (r >= mid + 1) {
      upd(T->R, mid + 1, high);
    }
    merge(T);
  }
  int qwr(Node* T, int low, int high) {
    if (l <= low && r >= high) {
      return T->val;
    }
    if (T->L == nullptr && T->R == nullptr) {
      return T->val;
    }
    int mid = ((low + high) >> 1);
    if (T->L != nullptr) push(T->L);
    if (T->R != nullptr) push(T->R);
    int resLeft = 0;
    int resRight = 0;
    if (l <= mid && T->L != nullptr) resLeft = qwr(T->L, low, mid);
    if (r >= mid + 1 && T->R != nullptr) resRight = qwr(T->R, mid + 1, high);
    return max(resLeft, resRight);
  }
  Node* fetchNode(int s = 0, Node* left = nullptr, Node* right = nullptr) {
    tree.push_back(Node(s, left, right));
    return &tree.back();
  }
  int n, l, r, val;
  Node* root;
  deque<Node> tree;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  DynamicSegmentTree DST_X(1e9 + 9);
  DynamicSegmentTree DST_Y(1e9 + 9);
  int n, q;
  cin >> n >> q;
  while (q--) {
    int x, y;
    char type;
    cin >> x >> y >> type;
    if (type == 'L') {
      int pos = DST_Y.qwr(y, y);
      if (pos > x || DST_X.qwr(x, x) == y) {
        cout << 0 << "\n";
        continue;
      }
      cout << x - pos << "\n";
      DST_X.upd(pos + 1, x, y);
    } else {
      int pos = DST_X.qwr(x, x);
      if (pos > y || DST_Y.qwr(y, y) == x) {
        cout << 0 << "\n";
        continue;
      }
      cout << y - pos << "\n";
      DST_Y.upd(pos + 1, y, x);
    }
  }
  return 0;
}
