#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
struct info {
  map<long long, long long> same;
  set<long long> other;
};
int main() {
  std::ios_base::sync_with_stdio(false);
  enum direction_type { UP, LEFT };
  info a[2];
  set<long long> visited;
  int N, Q;
  cin >> N >> Q;
  for (int i = 0; i < Q; i++) {
    int x, y, dd;
    char d;
    cin >> x >> y >> d;
    if (visited.find(x) != visited.end()) {
      cout << 0 << endl;
      continue;
    }
    visited.insert(x);
    int cur;
    if (d == 'U') {
      dd = 0;
      cur = x;
    } else {
      dd = 1;
      cur = y;
    }
    info& cur_a = a[dd];
    info& opp_a = a[!dd];
    auto prev_same = cur_a.same.lower_bound(cur);
    auto prev_other = cur_a.other.lower_bound(cur);
    int res;
    if (prev_other == cur_a.other.end()) {
      res = N - cur + 1;
      cur_a.same.insert(make_pair(cur, N + 1));
      opp_a.other.insert(N - cur + 1);
    } else {
      if (prev_same != cur_a.same.end() && prev_same->first < *prev_other) {
        res = prev_same->second - cur;
        cur_a.same.insert(make_pair(cur, prev_same->second));
        opp_a.other.insert(N - cur + 1);
      } else {
        res = *prev_other - cur;
        cur_a.same.insert(make_pair(cur, *prev_other));
        opp_a.other.insert(N - cur + 1);
      }
    }
    cout << res << endl;
  }
  return 0;
}
