#include <bits/stdc++.h>
using namespace std;
set<int> s;
map<int, int> m, val;
int main() {
  int n, q, i, ans = 0, x, y, z;
  char c;
  scanf("%d%d", &n, &q);
  s.insert(0);
  s.insert(n + 1);
  set<int>::iterator it;
  for (i = 0; i < q; i++) {
    cin >> x >> y >> c;
    if (m[y]) {
      printf("0\n");
      continue;
    }
    if (c == 'U') {
      it = s.lower_bound(y);
      it--;
      if (*it == 0) {
        printf("%d\n", y);
        val[y] = y;
      } else if (m[*it] == 1) {
        printf("%d\n", val[*it] + y - *it);
        val[y] = val[*it] + y - *it;
      } else {
        printf("%d\n", y - *it);
        val[y] = y - *it;
      }
      m[y] = 1;
      s.insert(y);
    } else {
      it = s.lower_bound(y);
      if (*it == n + 1) {
        printf("%d\n", x);
        val[y] = x;
      } else if (m[*it] == 1) {
        printf("%d\n", abs((n + 1 - *it) - x));
        val[y] = abs((n + 1 - *it) - x);
      } else {
        printf("%d\n", val[*it] + abs((n + 1 - *it) - x));
        val[y] = val[*it] + abs((n + 1 - *it) - x);
      }
      m[y] = 2;
      s.insert(y);
    }
  }
  return 0;
}
