#include <bits/stdc++.h>
using namespace std;
int n, q, x, y, ans;
char ch;
map<int, pair<char, int> > mp;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> q;
  mp[0] = {'U', 0};
  mp[n + 1] = {'L', 0};
  while (q--) {
    cin >> x >> y >> ch;
    auto it = mp.lower_bound(x);
    if (it->first == x) {
      cout << "0\n";
      continue;
    }
    if (ch == 'L') --it;
    ans = abs(x - it->first);
    if (ch == it->second.first) ans += it->second.second;
    cout << ans << "\n";
    mp[x] = {ch, ans};
  }
  return 0;
}
