#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
map<int, pair<int, char>> previous;
int query(int x, char d) {
  auto i = previous.lower_bound(x);
  if (i->first == x) return 0;
  if (d == 'L') --i;
  auto len = abs(i->first - x);
  len += (d == i->second.second) * i->second.first;
  previous.emplace(piecewise_construct, forward_as_tuple(x),
                   forward_as_tuple(len, d));
  return len;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  previous[0] = {0, 'U'};
  previous[n + 1] = {0, 'L'};
  for (int i = 0; i < q; ++i) {
    int x, y;
    char d;
    cin >> x >> y >> d;
    cout << query(x, d) << '\n';
  }
  return 0;
}
