#include <bits/stdc++.h>
using namespace std;
const int inft = 1000000009;
const int MAXN = 1000006;
const int T = 1024 * 1024;
int drz[2][2 * T];
vector<int> X;
pair<int, int> Q[MAXN];
char C[MAXN];
bool used[MAXN];
int ask(int a, int nr) {
  int ans = -1;
  a += T;
  while (a) {
    ans = max(ans, drz[nr][a]);
    a /= 2;
  }
  return ans;
}
void add(int a, int b, int value, int nr) {
  a += T;
  b += T;
  while (a <= b) {
    if (a % 2 == 1) {
      drz[nr][a] = max(drz[nr][a], value);
      a++;
    }
    if (b % 2 == 0) {
      drz[nr][b] = max(drz[nr][b], value);
      b--;
    }
    a /= 2;
    b /= 2;
  }
}
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  X.push_back(0);
  X.push_back(n + 1);
  for (int i = 0; i < (m); ++i) {
    int a, b;
    char c;
    scanf("%d%d %c", &a, &b, &c);
    X.push_back(a);
    X.push_back(b);
    Q[i] = pair<int, int>(a, b);
    C[i] = c;
  }
  sort((X).begin(), (X).end());
  X.resize(unique((X).begin(), (X).end()) - X.begin());
  for (int j = 0; j < (2); ++j)
    for (int i = 0; i < (2 * T); ++i) drz[j][i] = -1;
  add(0, T - 1, 0, 0);
  add(0, T - 1, 0, 1);
  for (int i = 0; i < (m); ++i) {
    int aa = lower_bound((X).begin(), (X).end(), Q[i].first) - X.begin();
    if (used[aa]) {
      printf("0\n");
      continue;
    }
    used[aa] = 1;
    if (C[i] == 'L') {
      int nr = lower_bound((X).begin(), (X).end(), Q[i].second) - X.begin();
      int ans = ask(nr, 0);
      printf("%d\n", Q[i].first - X[ans]);
      add(ans, lower_bound((X).begin(), (X).end(), Q[i].first) - X.begin(), nr,
          1);
    } else {
      int nr = lower_bound((X).begin(), (X).end(), Q[i].first) - X.begin();
      int ans = ask(nr, 1);
      printf("%d\n", Q[i].second - X[ans]);
      add(ans, lower_bound((X).begin(), (X).end(), Q[i].second) - X.begin(), nr,
          0);
    }
  }
}
int main() {
  int t = 1;
  for (int i = 0; i < (t); ++i) solve();
  return 0;
}
