#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > s;
map<int, int> mp;
int n, q;
int main() {
  scanf("%d%d", &n, &q);
  s.insert(make_pair(0, 1));
  s.insert(make_pair(n + 1, 0));
  for (; q--;) {
    int x, y;
    char c;
    scanf("%d%d %c", &x, &y, &c);
    if (mp.count(x)) {
      printf("0\n");
      continue;
    }
    if (c == 'U') {
      pair<int, int> p = *s.lower_bound(make_pair(x, -1));
      if (p.second == 1)
        mp[x] = p.first - x + mp[p.first];
      else
        mp[x] = p.first - x;
      s.insert(make_pair(x, 1));
    } else {
      set<pair<int, int> >::iterator it = s.lower_bound(make_pair(x, -1));
      it--;
      pair<int, int> p = *it;
      if (p.second == 0)
        mp[x] = x - p.first + mp[p.first];
      else
        mp[x] = x - p.first;
      s.insert(make_pair(x, 0));
    }
    cout << mp[x] << "\n";
  }
}
