#include <bits/stdc++.h>
using namespace std;
int n, q, x, y, ans;
char ch[2];
map<int, int> Left, Up;
map<int, int>::iterator it;
int main() {
  ios::sync_with_stdio(false);
  while (scanf("%d%d", &n, &q) != EOF) {
    Left.clear();
    Up.clear();
    while (q--) {
      scanf("%d%d%s", &x, &y, ch);
      if (Up.find(x) != Up.end()) {
        printf("0\n");
        continue;
      }
      if (ch[0] == 'U') {
        it = Up.lower_bound(x);
        if (it == Up.end()) {
          ans = y;
          Up[x] = 0;
        } else {
          ans = y - it->second;
          Up[x] = it->second;
        }
        Left[y] = x;
      } else {
        it = Left.lower_bound(y);
        if (it == Left.end()) {
          ans = x;
          Left[y] = 0;
        } else {
          ans = x - it->second;
          Left[y] = it->second;
        }
        Up[x] = y;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
