#include <bits/stdc++.h>
using namespace std;
map<int, bool> check;
set<pair<int, pair<char, int> > > s;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  s.insert(make_pair(n + 1, make_pair('L', n)));
  s.insert(make_pair(0, make_pair('U', 1)));
  while (q--) {
    int x, y, k = 0;
    cin >> x >> y;
    char type;
    cin >> type;
    if (check[x]) {
      cout << 0 << endl;
      continue;
    }
    check[x] = true;
    set<pair<int, pair<char, int> > >::iterator z =
        s.upper_bound(make_pair(x, make_pair('.', 0)));
    if (type == 'U') {
      if ((*z).second.first == 'U') {
        k = (*z).second.second;
      } else {
        k = (*z).first - 1;
      }
      cout << k - x + 1 << endl;
    } else {
      z--;
      if ((*z).second.first == 'L') {
        k = (*z).second.second;
      } else {
        k = (*z).first + 1;
      }
      cout << x - k + 1 << endl;
    }
    s.insert(make_pair(x, make_pair(type, k)));
  }
}
