#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 256;
const char nxt = '\n';
inline void in(string Q) {
  Q += ".in";
  freopen(Q.c_str(), "r", stdin);
}
inline void out(string Q) {
  Q += ".out";
  freopen(Q.c_str(), "w", stdout);
}
inline void open_file(string Q) {
  in(Q);
  out(Q);
}
set<pair<int, char> > query;
map<pair<int, char>, int> res;
int n, q;
int main() {
  if (0) open_file("");
  scanf("%d", &n);
  scanf("%d", &q);
  query.insert(make_pair(n + 1, 'U'));
  query.insert(make_pair(0, 'L'));
  for (; q--;) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    char c;
    cin >> c;
    if (query.count(make_pair(x, 'L')) || query.count(make_pair(x, 'U'))) {
      cout << 0 << nxt;
      continue;
    }
    int ans;
    if (c == 'U') {
      auto it = query.upper_bound(make_pair(x, '0'));
      if (it->second == 'L')
        ans = (n + 1 - x) - (n + 1 - it->first);
      else
        ans = (n + 1 - x) - (n + 1 - it->first), ans += res[*it];
    } else {
      auto it = query.upper_bound(make_pair(x, '0'));
      it--;
      if (it->second == 'U')
        ans = x - it->first;
      else
        ans = (x - it->first), ans += res[*it];
    }
    res[make_pair(x, c)] = ans;
    query.insert(make_pair(x, c));
    cout << ans << nxt;
  }
  return 0;
}
