#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const int MAX = 5e6;
int N;
namespace seg1 {
int seg[MAX], lazy[MAX], R[MAX], L[MAX], ptr;
int get_l(int i) {
  if (L[i] == 0) {
    seg[ptr] = seg[i];
    L[i] = ptr++;
  }
  return L[i];
}
int get_r(int i) {
  if (R[i] == 0) {
    seg[ptr] = seg[i];
    R[i] = ptr++;
  }
  return R[i];
}
void build() {
  ptr = 2;
  seg[1] = 0;
}
void prop(int p, int l, int r) {
  if (lazy[p] == 0) return;
  if (l != r) {
    lazy[get_l(p)] = max(lazy[get_l(p)], lazy[p]);
    lazy[get_r(p)] = max(lazy[get_r(p)], lazy[p]);
    seg[get_l(p)] = max(seg[get_l(p)], lazy[p]);
    seg[get_r(p)] = max(seg[get_r(p)], lazy[p]);
  }
  lazy[p] = 0;
}
int query(int a, int b, int p = 1, int l = 0, int r = N - 1) {
  if (b < l or r < a) return 0;
  if (a <= l and r <= b) return seg[p];
  prop(p, l, r);
  int m = (l + r) / 2;
  return max(query(a, b, get_l(p), l, m), query(a, b, get_r(p), m + 1, r));
}
int update(int a, int b, int val, int p = 1, int l = 0, int r = N - 1) {
  if (b < l or r < a) return seg[p];
  if (a <= l and r <= b) {
    lazy[p] = max(lazy[p], val);
    seg[p] = max(seg[p], val);
    return seg[p];
  }
  prop(p, l, r);
  int m = (l + r) / 2;
  return seg[p] = max(update(a, b, val, get_l(p), l, m),
                      update(a, b, val, get_r(p), m + 1, r));
}
};  // namespace seg1
namespace seg2 {
int seg[MAX], lazy[MAX], R[MAX], L[MAX], ptr;
int get_l(int i) {
  if (L[i] == 0) {
    seg[ptr] = seg[i];
    L[i] = ptr++;
  }
  return L[i];
}
int get_r(int i) {
  if (R[i] == 0) {
    seg[ptr] = seg[i];
    R[i] = ptr++;
  }
  return R[i];
}
void build() {
  ptr = 2;
  seg[1] = 0;
}
void prop(int p, int l, int r) {
  if (lazy[p] == 0) return;
  if (l != r) {
    lazy[get_l(p)] = max(lazy[get_l(p)], lazy[p]);
    lazy[get_r(p)] = max(lazy[get_r(p)], lazy[p]);
    seg[get_l(p)] = max(seg[get_l(p)], lazy[p]);
    seg[get_r(p)] = max(seg[get_r(p)], lazy[p]);
  }
  lazy[p] = 0;
}
int query(int a, int b, int p = 1, int l = 0, int r = N - 1) {
  if (b < l or r < a) return 0;
  if (a <= l and r <= b) return seg[p];
  prop(p, l, r);
  int m = (l + r) / 2;
  return max(query(a, b, get_l(p), l, m), query(a, b, get_r(p), m + 1, r));
}
int update(int a, int b, int val, int p = 1, int l = 0, int r = N - 1) {
  if (b < l or r < a) return seg[p];
  if (a <= l and r <= b) {
    lazy[p] = max(lazy[p], val);
    seg[p] = max(seg[p], val);
    return seg[p];
  }
  prop(p, l, r);
  int m = (l + r) / 2;
  return seg[p] = max(update(a, b, val, get_l(p), l, m),
                      update(a, b, val, get_r(p), m + 1, r));
}
};  // namespace seg2
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  seg1::build();
  seg2::build();
  N = n + 3;
  set<int> usd;
  for (int i = 0; i < q; i++) {
    char c;
    int x, y;
    cin >> x >> y >> c;
    if (c == 'L') {
      if (usd.count(x)) {
        cout << 0 << '\n';
        continue;
      }
      usd.insert(x);
      int maxi = seg2::query(y, y);
      cout << x - maxi << '\n';
      seg1::update(maxi, x, y);
    } else {
      if (usd.count(x)) {
        cout << 0 << '\n';
        continue;
      }
      usd.insert(x);
      int maxi = seg1::query(x, x);
      ;
      cout << y - maxi << '\n';
      seg2::update(maxi, y, x);
    }
  }
  return 0;
}
