#include <bits/stdc++.h>
using namespace std;
map<int, int> row;
map<int, int> col;
int main() {
  int N, Q;
  scanf("%d%d", &N, &Q);
  col[0] = N + 1;
  row[0] = N + 1;
  while (Q--) {
    int x, y;
    char ch[2];
    scanf("%d%d%s", &x, &y, ch);
    if (row.count(y) || col.count(x)) {
      printf("0\n");
      continue;
    }
    auto c = col.lower_bound(x);
    auto r = row.lower_bound(y);
    int ans = 0;
    if (ch[0] == 'L') {
      c--;
      if (r == row.end()) {
        if (N + 1 - c->first - c->second > y)
          ans = x;
        else
          ans = x - c->first;
      } else {
        if (N + 1 - c->first - c->second > y)
          ans = x;
        else
          ans = x - c->first;
        ans = min(ans, r->second + (r->first - y));
      }
      row[y] = ans;
    } else {
      r--;
      if (c == col.end()) {
        if (N + 1 - r->first - r->second > x)
          ans = y;
        else
          ans = y - r->first;
      } else {
        if (N + 1 - r->first - r->second > x)
          ans = y;
        else
          ans = y - r->first;
        ans = min(ans, c->second + (c->first - x));
      }
      col[x] = ans;
    }
    printf("%d\n", ans);
  }
}
