#include <bits/stdc++.h>
using namespace std;
const int MN = 13000009, INF = 1196969696;
int MIN[MN], MAX[MN], lewy[MN], prawy[MN];
int P2 = 1, lastNode;
map<int, int> bylo[2];
void ustawMin(int x, int v, int curr, int l, int p) {
  if (l == p && l == x) {
    MIN[curr] = v;
    return;
  }
  int mid = (l + p) >> 1;
  if (x <= mid) {
    if (!lewy[curr]) lewy[curr] = ++lastNode;
    ustawMin(x, v, lewy[curr], l, mid);
  } else {
    if (!prawy[curr]) prawy[curr] = ++lastNode;
    ustawMin(x, v, prawy[curr], mid + 1, p);
  }
  MIN[curr] = min(MIN[lewy[curr]], MIN[prawy[curr]]);
}
int mini(int a, int b, int curr, int l, int p) {
  if (l == a && p == b) return MIN[curr];
  int mid = (l + p) >> 1;
  int res = INF;
  if (a <= mid && lewy[curr])
    res = min(res, mini(a, min(b, mid), lewy[curr], l, mid));
  if (b > mid && prawy[curr])
    res = min(res, mini(max(a, mid + 1), b, prawy[curr], mid + 1, p));
  return res;
}
void ustawMax(int a, int b, int v, int curr, int l, int p) {
  if (a > b) return;
  if (a == l && b == p) {
    MAX[curr] = max(MAX[curr], v);
  } else {
    int mid = (l + p) >> 1;
    if (a <= mid) {
      if (!lewy[curr]) lewy[curr] = ++lastNode;
      ustawMax(a, min(b, mid), v, lewy[curr], l, mid);
    }
    if (b > mid) {
      if (!prawy[curr]) prawy[curr] = ++lastNode;
      ustawMax(max(a, mid + 1), b, v, prawy[curr], mid + 1, p);
    }
  }
}
int maxi(int x, int curr, int l, int p) {
  if (l == x && p == x) return MAX[curr];
  int mid = (l + p) >> 1;
  int res = MAX[curr];
  if (x <= mid && lewy[curr]) res = max(res, maxi(x, lewy[curr], l, mid));
  if (x > mid && prawy[curr]) res = max(res, maxi(x, prawy[curr], mid + 1, p));
  return res;
}
int BS(int a, int b) {
  int zd = 1, zg = a;
  if (mini(a, a, 2, 0, P2 - 1) <= b) return a + 1;
  while (zd != zg) {
    int mid = (zd + zg) >> 1;
    if (mini(mid, a, 2, 0, P2 - 1) <= b)
      zd = mid;
    else
      zg = mid;
    if (zd + 1 == zg) {
      if (mini(zd, a, 2, 0, P2 - 1) > b)
        zg = zd;
      else
        zd = zg;
    }
  }
  return zd;
}
int main() {
  MIN[0] = INF;
  lastNode = 2;
  int n, q;
  scanf("%d%d", &n, &q);
  while (P2 <= n) P2 <<= 1;
  while (q--) {
    int a, b;
    char co[3];
    scanf("%d%d%s", &a, &b, co);
    if (co[0] == 'L') {
      if (bylo[0][a]) {
        printf("0\n");
        continue;
      }
      bylo[0][a] = 1;
      int g = BS(a, b);
      printf("%d\n", a - g + 1);
      ustawMax(g, a, b, 1, 0, P2 - 1);
    } else {
      if (bylo[1][a]) {
        printf("0\n");
        continue;
      }
      bylo[1][a] = 1;
      int g = maxi(a, 1, 0, P2 - 1);
      printf("%d\n", b - g);
      ustawMin(a, g + 1, 2, 0, P2 - 1);
    }
  }
}
