#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void smax(T &x, T y) {
  x = max((x), (y));
}
template <class T>
inline void smin(T &x, T y) {
  x = min((x), (y));
}
const int MOD = 1e9 + 7;
const int SIZE = 1e5 + 10;
int n, q;
void printset(set<pair<pair<int, int>, int> > &st) {
  for (set<pair<pair<int, int>, int> >::iterator it = st.begin();
       it != st.end(); it++) {
    printf("%d %d %d\n", it->first.first, it->first.second, it->second);
  }
}
int main() {
  if (0) {
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
  }
  while (cin >> n >> q) {
    set<pair<pair<int, int>, int> > rowset, colset;
    rowset.insert(make_pair(make_pair(1, n), 0)),
        colset.insert(make_pair(make_pair(1, n), 0));
    for (int i = 0; i < (q); ++i) {
      int r, c;
      char type;
      cin >> c >> r >> type;
      if (type == 'L') {
        set<pair<pair<int, int>, int> >::iterator up =
            rowset.upper_bound(make_pair(make_pair(r, n + 1), 0));
        up--;
        int ma = up->second;
        int lef = up->first.first, rig = up->first.second;
        if (!(lef <= r && rig >= r)) {
          printf("0\n");
          continue;
        }
        printf("%d\n", c - ma);
        rowset.erase(up);
        rowset.insert(make_pair(make_pair(lef, r - 1), ma));
        rowset.insert(make_pair(make_pair(r + 1, rig), ma));
        up = colset.upper_bound(make_pair(make_pair(c, n + 1), 0));
        up--;
        int ma2 = up->second;
        lef = up->first.first, rig = up->first.second;
        colset.erase(up);
        colset.insert(make_pair(make_pair(lef, c - 1), r));
        colset.insert(make_pair(make_pair(c + 1, rig), ma2));
      } else {
        set<pair<pair<int, int>, int> >::iterator up =
            colset.upper_bound(make_pair(make_pair(c, n + 1), 0));
        up--;
        int ma = up->second;
        int lef = up->first.first, rig = up->first.second;
        if (!(lef <= c && rig >= c)) {
          printf("0\n");
          continue;
        }
        printf("%d\n", r - ma);
        colset.insert(make_pair(make_pair(lef, c - 1), ma));
        colset.insert(make_pair(make_pair(c + 1, rig), ma));
        colset.erase(up);
        up = rowset.upper_bound(make_pair(make_pair(r, n + 1), 0));
        up--;
        int ma2 = up->second;
        lef = up->first.first, rig = up->first.second;
        rowset.insert(make_pair(make_pair(lef, r - 1), c));
        rowset.insert(make_pair(make_pair(r + 1, rig), ma2));
        rowset.erase(up);
      }
    }
  }
  return 0;
}
