#include <bits/stdc++.h>
using namespace std;
long long n, q, x[200100], y[200100];
long long lzy1[800200], lzy2[800200], seg1[800200], seg2[800200];
map<long long, long long> m1, m2;
map<pair<long long, long long>, bool> vis;
char d[200200];
void update1(int st, int en, int l, int r, int id, long long val) {
  if (st > r || en < l) return;
  if (l >= st && r <= en) {
    seg1[id] = max(val, seg1[id]);
    return;
  }
  int mid = (l + r) / 2;
  seg1[2 * id] = max(seg1[2 * id], seg1[id]);
  seg1[2 * id + 1] = max(seg1[2 * id + 1], seg1[id]);
  update1(st, en, l, mid, 2 * id, val);
  update1(st, en, mid + 1, r, 2 * id + 1, val);
}
long long query1(int idx, int l, int r, int id) {
  if (l > idx || r < idx) return 0;
  if (l == r && l == idx) return seg1[id];
  int mid = (l + r) / 2;
  seg1[2 * id] = max(seg1[2 * id], seg1[id]);
  seg1[2 * id + 1] = max(seg1[2 * id + 1], seg1[id]);
  if (idx <= mid) {
    return query1(idx, l, mid, 2 * id);
  }
  return query1(idx, mid + 1, r, 2 * id + 1);
}
void update2(int st, int en, int l, int r, int id, long long val) {
  if (st > r || en < l) return;
  if (l >= st && r <= en) {
    seg2[id] = max(val, seg2[id]);
    return;
  }
  int mid = (l + r) / 2;
  seg2[2 * id] = max(seg2[2 * id], seg2[id]);
  seg2[2 * id + 1] = max(seg2[2 * id + 1], seg2[id]);
  update2(st, en, l, mid, 2 * id, val);
  update2(st, en, mid + 1, r, 2 * id + 1, val);
}
long long query2(int idx, int l, int r, int id) {
  if (l > idx || r < idx) return 0;
  if (l == r) return seg2[id];
  int mid = (l + r) / 2;
  seg2[2 * id] = max(seg2[2 * id], seg2[id]);
  seg2[2 * id + 1] = max(seg2[2 * id + 1], seg2[id]);
  if (idx <= mid) {
    return query2(idx, l, mid, 2 * id);
  }
  return query2(idx, mid + 1, r, 2 * id + 1);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> q;
  for (int i = 0; i < q; i++) {
    cin >> y[i] >> x[i] >> d[i];
    m1[x[i]] = 1;
    m2[y[i]] = 1;
  }
  map<long long, long long>::iterator it;
  long long i = 1;
  for (it = m1.begin(); it != m1.end(); it++, i++) {
    it->second = i;
  }
  i = 1;
  for (it = m2.begin(); it != m2.end(); it++, i++) it->second = i;
  long long n1 = m1.size();
  long long n2 = m2.size();
  for (int i = 0; i < q; i++) {
    if (vis[{y[i], x[i]}]) {
      cout << "0\n";
      continue;
    }
    vis[{y[i], x[i]}] = 1;
    if (d[i] == 'U') {
      int qe = query2(m2[y[i]], 1, n2, 1);
      cout << x[i] - qe << "\n";
      update1(m1[qe], m1[x[i]], 1, n1, 1, y[i]);
    } else {
      int qe = query1(m1[x[i]], 1, n1, 1);
      cout << y[i] - qe << "\n";
      update2(m2[qe], m2[y[i]], 1, n2, 1, x[i]);
    }
  }
  return 0;
}
