#include <bits/stdc++.h>
using namespace std;
int n, m;
map<int, pair<char, int> > mp;
int x, y;
char c;
void query() {
  cin >> x >> y >> c;
  auto yy = mp.lower_bound(x);
  if (yy->first == x) {
    cout << "0" << endl;
    return;
  }
  if (c == 'L') {
    yy--;
  }
  int res = abs(yy->first - x);
  if (yy->second.first == c) {
    res += yy->second.second;
  }
  cout << res << endl;
  mp[x] = {c, res};
}
int main() {
  cin >> n >> m;
  mp[0] = {'U', 0};
  mp[n + 1] = {'L', 0};
  for (int i = 0; i < m; i++) {
    query();
  }
  return 0;
}
