#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
map<int, pair<char, int> > ma;
map<int, pair<char, int> >::iterator it;
int ans = 0, n, m, x, y;
string s;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  ma[0] = pair<char, int>('U', 0);
  ma[n + 1] = pair<char, int>('L', 0);
  while (m--) {
    cin >> x >> y >> s;
    ans = 0;
    it = ma.lower_bound(x);
    if (it->first == x) {
      cout << "0\n";
      continue;
    }
    if (s[0] == 'L') it--;
    ans = abs((it->first) - x);
    if (it->second.first == s[0]) ans += it->second.second;
    cout << ans << endl;
    ma[x] = pair<char, int>(s[0], ans);
  }
  return 0;
}
