#include <bits/stdc++.h>
using namespace std;
int n, q, p, x, y;
map<int, pair<char, int> > m;
int qq() {
  char c;
  scanf("%d%d %c", &x, &y, &c);
  map<int, pair<char, int> >::iterator b = m.lower_bound(x);
  if (b->first == x) return 0;
  if (c == 'L') --b;
  int ans = abs(b->first - x);
  if (b->second.first == c) ans += b->second.second;
  m[x] = {c, ans};
  return ans;
}
int main() {
  int i;
  cin >> n >> q;
  m[0] = {'U', 0};
  m[n + 1] = {'L', 0};
  for (i = 1; i <= q; i++) {
    cout << qq() << endl;
  }
  return 0;
}
