#include <bits/stdc++.h>
using namespace std;
set<int> U;
map<int, int> mp;
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  int i;
  map<int, int>::iterator it;
  for (i = 1; i <= q; i++) {
    int x, y;
    char s[2];
    scanf("%d%d%s", &x, &y, s);
    int to;
    if (mp.find(x) != mp.end()) {
      printf("0\n");
      continue;
    }
    if (s[0] == 'U') {
      it = mp.upper_bound(x);
      if (it == mp.end()) {
        to = 1;
      } else {
        if (U.find(it->first) != U.end()) {
          to = it->second;
        } else {
          to = n + 1 - it->first + 1;
        }
      }
      U.insert(x);
      mp[x] = to;
      printf("%d\n", y - to + 1);
    } else {
      it = mp.lower_bound(x);
      if (it == mp.begin()) {
        to = 1;
      } else {
        it--;
        if (U.find(it->first) != U.end()) {
          to = it->first + 1;
        } else {
          to = it->second;
        }
      }
      mp[x] = to;
      printf("%d\n", x - to + 1);
    }
  }
  return 0;
}
