#include <bits/stdc++.h>
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
using namespace std;
pair<pair<int, int>, int> qry[MAXN];
char tmp[MAXN];
vector<int> arr, v;
int tree[2][MAXN], inv[MAXN];
int n;
unordered_map<int, int> ans;
void build(int l, int r, int k) {
  if (l == r) {
    tree[0][k] = l + 1;
    tree[1][k] = l - 1;
    return;
  }
  int m = (l + r) >> 1;
  build(l, m, k << 1);
  build(m + 1, r, k << 1 | 1);
  tree[0][k] = min(tree[0][k << 1], tree[0][k << 1 | 1]);
  tree[1][k] = max(tree[1][k << 1], tree[1][k << 1 | 1]);
}
int queryu(int l, int r, int k, int x) {
  if (tree[0][k] > x) return -1;
  if (l == r) return l;
  int m = (l + r) >> 1;
  if (m >= x) {
    int id = queryu(l, m, k << 1, x);
    if (id != -1) return id;
  }
  return queryu(m + 1, r, k << 1 | 1, x);
}
int queryl(int l, int r, int k, int x) {
  if (tree[1][k] < x) return -1;
  if (l == r) return l;
  int m = (l + r) >> 1;
  if (m < x) {
    int id = queryl(m + 1, r, k << 1 | 1, x);
    if (id != -1) return id;
  }
  return queryl(l, m, k << 1, x);
}
void updu(int l, int r, int k, int x, int val) {
  if (r < x || l > x) return;
  if (x <= l && r <= x) {
    tree[1][k] = max(tree[1][k], val);
    return;
  }
  int m = (l + r) >> 1;
  updu(l, m, k << 1, x, val);
  updu(m + 1, r, k << 1 | 1, x, val);
  tree[1][k] = max(tree[1][k << 1], tree[1][k << 1 | 1]);
}
void updl(int l, int r, int k, int x, int val) {
  if (r < x || l > x) return;
  if (x <= l && r <= x) {
    tree[0][k] = min(tree[0][k], val);
    return;
  }
  int m = (l + r) >> 1;
  updl(l, m, k << 1, x, val);
  updl(m + 1, r, k << 1 | 1, x, val);
  tree[0][k] = min(tree[0][k << 1], tree[0][k << 1 | 1]);
}
int main() {
  int q;
  scanf("%d", &(n)), scanf("%d", &(q));
  for (int i = 0; i < q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    scanf("%s", tmp);
    x--;
    y = n - y;
    if (tmp[0] == 'L')
      qry[i] = {{x, y}, 0};
    else
      qry[i] = {{x, y}, 1};
    arr.push_back(x);
  }
  build(0, q - 1, 1);
  sort(arr.begin(), arr.end());
  arr.resize(unique(arr.begin(), arr.end()) - arr.begin());
  for (int i = 0; i < q; i++)
    inv[lower_bound(arr.begin(), arr.end(), qry[i].first.first) - arr.begin()] =
        qry[i].first.first;
  for (int i = 0; i < q; i++) {
    int x =
        lower_bound(arr.begin(), arr.end(), qry[i].first.first) - arr.begin();
    if (ans.find(x) != ans.end()) {
      printf("%d\n", (0));
      continue;
    }
    int y = qry[i].first.second;
    int val;
    if (qry[i].second) {
      val = queryu(0, q - 1, 1, x);
      updu(0, q - 1, 1, x, val == -1 ? n : val);
      updl(0, q - 1, 1, x, x);
      if (val == -1)
        val = n;
      else
        val = inv[val];
      printf("%d\n", (val - y));
      ans[x] = val - y;
    } else {
      val = queryl(0, q - 1, 1, x);
      updl(0, q - 1, 1, x, val);
      updu(0, q - 1, 1, x, x);
      if (val == -1)
        val = -1;
      else
        val = inv[val];
      printf("%d\n", (qry[i].first.first - val));
      ans[x] = qry[i].first.first - val;
    }
  }
  return 0;
}
