#include <bits/stdc++.h>
using namespace std;
int n, q;
const int maxn = 2e5;
vector<pair<pair<int, int>, char> > queries;
set<int> sr, sc;
vector<int> cs, rs;
map<int, int> rtoi, ctoi;
struct segmentTree {
  int N;
  int MAX;
  vector<int> tree;
  vector<int> lazy;
  vector<int> arr;
  int defaultValue = -1;
  segmentTree(const vector<int>& inputArray) {
    N = inputArray.size();
    MAX = 4 * N;
    tree.resize(MAX, 0);
    lazy.resize(MAX, defaultValue);
    arr = inputArray;
    build_tree(1, 0, N - 1);
  }
  int join(const int& v1, const int& v2) { return max(v1, v2); }
  void propagate(int node, int a, int b) {
    if (lazy[node] != defaultValue) {
      tree[node] = max(tree[node], lazy[node]);
      if (a != b) {
        lazy[node * 2] = max(lazy[node * 2], lazy[node]);
        lazy[node * 2 + 1] = max(lazy[node * 2 + 1], lazy[node]);
      }
      lazy[node] = defaultValue;
    }
  }
  void build_tree(int node, int a, int b) {
    if (a > b) return;
    if (a == b) {
      tree[node] = arr[a];
      return;
    }
    build_tree(node * 2, a, (a + b) / 2);
    build_tree(node * 2 + 1, 1 + (a + b) / 2, b);
    tree[node] = join(tree[node * 2], tree[node * 2 + 1]);
  }
  void update_tree(int node, int a, int b, int i, int j, int value) {
    propagate(node, a, b);
    if (a > b || a > j || b < i) return;
    if (a >= i && b <= j) {
      lazy[node] = value;
      propagate(node, a, b);
      return;
    }
    update_tree(node * 2, a, (a + b) / 2, i, j, value);
    update_tree(1 + node * 2, 1 + (a + b) / 2, b, i, j, value);
    tree[node] = join(tree[node * 2], tree[node * 2 + 1]);
  }
  int query_tree(int node, int a, int b, int i, int j) {
    if (a > b || a > j || b < i) return 0;
    propagate(node, a, b);
    if (a >= i && b <= j) return tree[node];
    int q1 = query_tree(node * 2, a, (a + b) / 2, i, j);
    int q2 = query_tree(1 + node * 2, 1 + (a + b) / 2, b, i, j);
    int res = join(q1, q2);
    return res;
  }
  void update_tree(int a, int b, int val) {
    update_tree(1, 0, N - 1, a, b, val);
  }
  int query_tree(int a, int b) { return query_tree(1, 0, N - 1, a, b); }
};
int main() {
  scanf("%d %d", &n, &q);
  rs.push_back(0);
  cs.push_back(0);
  while (q--) {
    int c, r;
    char ch;
    scanf("%d %d %c", &c, &r, &ch);
    queries.push_back(make_pair(make_pair(c, r), ch));
    sr.insert(r);
    sc.insert(c);
  }
  for (auto it = sr.begin(); it != sr.end(); it++) rs.push_back(*it);
  for (auto it = sc.begin(); it != sc.end(); it++) cs.push_back(*it);
  for (int i = 0; i < rs.size(); i++) rtoi[rs[i]] = i;
  for (int i = 0; i < cs.size(); i++) ctoi[cs[i]] = i;
  int vsize = max(rs.size(), cs.size());
  segmentTree s1 = segmentTree(vector<int>(vsize, 0));
  segmentTree s2 = segmentTree(vector<int>(vsize, 0));
  for (int it = 0; it < queries.size(); it++) {
    int c = queries[it].first.first;
    int r = queries[it].first.second;
    char ch = queries[it].second;
    int ci = ctoi[c];
    int ri = rtoi[r];
    if (ch == 'L') {
      int bb = s1.query_tree(ri, ri);
      int cf = cs[bb], ct = c;
      printf("%d\n", ct - cf);
      s2.update_tree(bb + 1, ci, ri);
      s1.update_tree(ri, ri, ci);
    } else {
      int bb = s2.query_tree(ci, ci);
      int rf = rs[bb], rt = r;
      printf("%d\n", rt - rf);
      s1.update_tree(bb + 1, ri, ci);
      s2.update_tree(ci, ci, ri);
    }
  }
  return 0;
}
