#include <bits/stdc++.h>
const double PI = acos(-1.0);
const int maxn = 1e5;
const int INF = 1e9;
using namespace std;
int n, q;
map<int, int> u;
map<int, int> l;
int main() {
  while (scanf("%d %d", &n, &q) != EOF) {
    u.clear();
    l.clear();
    while (q--) {
      map<int, int>::iterator p;
      int x, y;
      char op;
      scanf("%d %d", &x, &y);
      cin >> op;
      if (op == 'U') {
        int ans = 0;
        p = u.lower_bound(x);
        if (u.count(x)) {
          cout << 0 << endl;
          continue;
        }
        if (p == u.end())
          ans = y;
        else
          ans = y - (p->second);
        cout << ans << endl;
        l[y] = x;
        u[x] = y - ans;
      } else {
        int ans = 0;
        p = l.lower_bound(y);
        if (l.count(y)) {
          cout << 0 << endl;
          continue;
        }
        if (p == l.end())
          ans = x;
        else
          ans = x - (p->second);
        cout << ans << endl;
        u[x] = y;
        l[y] = x - ans;
      }
    }
  }
  return 0;
}
