#include <bits/stdc++.h>
using namespace std;
int n, q, x, y;
char type;
map<int, pair<char, int> > Data;
int solve() {
  auto fi = Data.lower_bound(x);
  if (fi->first == x) return 0;
  if (type == 'L') fi--;
  int ans = abs(x - fi->first);
  if (fi->second.first == type) ans += fi->second.second;
  Data[x] = make_pair(type, ans);
  return ans;
}
int main() {
  scanf("%d %d", &n, &q);
  Data[0] = make_pair('U', 0);
  Data[n + 1] = make_pair('L', 0);
  while (q--) {
    cin >> x >> y >> type;
    printf("%d\n", solve());
  }
}
