#include <bits/stdc++.h>
#pragma comment(linker, ”/ STACK : 36777216“)
int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
using namespace std;
int t[200011 << 2][2];
int get(int v, int tl, int tr, int pos, int K) {
  if (tl == tr) return t[v][K];
  int tm = (tl + tr) >> 1;
  if (pos <= tm)
    return max(t[v][K], get(v + v, tl, tm, pos, K));
  else
    return max(t[v][K], get(v + v + 1, tm + 1, tr, pos, K));
}
void update(int v, int tl, int tr, int l, int r, int first, int K) {
  if (max(l, tl) > min(r, tr)) return;
  if (tl >= l && r >= tr)
    t[v][K] = max(t[v][K], first);
  else {
    int tm = (tl + tr) >> 1;
    update(v + v, tl, tm, l, min(tm, r), first, K);
    update(v + v + 1, tm + 1, tr, max(tm + 1, l), r, first, K);
  }
}
map<int, int> N[2];
int first[200011][2];
char dir[200011];
bool used[200011][2];
vector<int> second[2];
int main() {
  int n, q;
  cin >> n >> q;
  for (int _n((q)-1), i(0); i <= _n; ++i)
    cin >> first[i][0] >> first[i][1] >> dir[i];
  for (int _n((2) - 1), i(0); i <= _n; ++i) {
    second[i].push_back(0);
    for (int _n((q)-1), j(0); j <= _n; ++j) second[i].push_back(first[j][i]);
  }
  for (int _n((2) - 1), i(0); i <= _n; ++i) {
    sort((second[i]).begin(), (second[i]).end());
    second[i].resize(unique((second[i]).begin(), (second[i]).end()) -
                     second[i].begin());
  }
  for (int _n((2) - 1), j(0); j <= _n; ++j)
    for (int _n((second[j].size()) - 1), i(0); i <= _n; ++i)
      N[j][second[j][i]] = i;
  for (int _n((q)-1), i(0); i <= _n; ++i) {
    int k = dir[i] != 'U';
    if (used[N[k][first[i][k]]][k]) {
      cout << 0 << endl;
      continue;
    }
    used[N[k][first[i][k]]][k] = 1;
    int X = get(1, 0, 200011, N[k][first[i][k]], k);
    cout << first[i][k ^ 1] - X << endl;
    update(1, 0, 200011, N[k ^ 1][X], N[k ^ 1][first[i][k ^ 1]], first[i][k],
           k ^ 1);
  }
  cin >> n;
  return 0;
}
