#include <bits/stdc++.h>
using namespace std;
int x, y;
char op[5];
map<int, int> u;
map<int, int> l;
int n, q;
int main() {
  scanf("%d %d", &n, &q);
  while (q--) {
    scanf("%d%d%s", &x, &y, op);
    map<int, int>::iterator p;
    if (op[0] == 'U') {
      p = u.lower_bound(x);
      int ans = 0;
      if (u.count(x)) {
        printf("0\n");
        continue;
      } else {
        if (p == u.end())
          ans = y;
        else
          ans = y - (p->second);
      }
      printf("%d\n", ans);
      l[y] = x;
      u[x] = y - ans;
    } else {
      p = l.lower_bound(y);
      int ans = 0;
      if (l.count(y)) {
        printf("0\n");
        continue;
      } else {
        if (p == l.end())
          ans = x;
        else
          ans = x - (p->second);
      }
      printf("%d\n", ans);
      u[x] = y;
      l[y] = x - ans;
    }
  }
  return 0;
}
