#include <bits/stdc++.h>
using namespace std;
map<long long, pair<char, long long> > m;
long long query() {
  char c;
  long long x, y;
  cin >> x >> y >> c;
  map<long long, pair<char, long long> >::iterator b = m.lower_bound(x);
  if ((*b).first == x) {
    return 0;
  }
  if (c == 'L') {
    b--;
  }
  long long ans = abs((*b).first - x);
  if ((*b).second.first == c) {
    ans += (*b).second.second;
  }
  m[x] = make_pair(c, ans);
  return ans;
}
signed main() {
  ios::sync_with_stdio(false);
  long long n, q;
  m[0] = make_pair('U', 0);
  cin >> n >> q;
  m[n + 1] = make_pair('L', 0);
  while (q--) {
    cout << query() << endl;
  }
  return 0;
}
