#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
const double eps = 1.0e-11;
const double pi = acos(-1.0);
using namespace std;
struct el {
  int x, y;
  char c;
  int old;
  int idx;
  bool operator<(const el& temp) const {
    if (x != temp.x) return x < temp.x;
    return old < temp.old;
  }
};
int main() {
  int n, q;
  cin >> n >> q;
  vector<el> v;
  vector<int> res(q + 2);
  set<pair<int, int> > used;
  for (int i = 0; i < q; i++) {
    el temp;
    char tc;
    scanf("%c%d %d %c", &tc, &temp.x, &temp.y, &temp.c);
    temp.old = i;
    temp.idx = i + 1;
    if (used.count(make_pair(temp.x, temp.y))) {
      res[i] = 0;
      continue;
    }
    used.insert(make_pair(temp.x, temp.y));
    v.push_back(temp);
  }
  v.push_back(el());
  v.back().x = 0;
  v.back().y = n + 1;
  v.back().c = 'U';
  v.back().old = -1;
  v.back().idx = 0;
  v.push_back(el());
  v.back().x = n + 1;
  v.back().y = 0;
  v.back().c = 'L';
  v.back().old = -1;
  v.back().idx = n + 1;
  sort(v.begin(), v.end());
  list<el> lst(v.begin(), v.end());
  list<el>::iterator cur = lst.begin();
  while (lst.size() != 2) {
    if (cur->c == 'U') {
      list<el>::iterator next = cur;
      next++;
      if (next->c == 'U')
        cur = next;
      else {
        if (cur->old > next->old) {
          res[cur->idx] = next->x - cur->x;
          lst.erase(cur);
          cur = next;
        } else {
          res[next->idx] = next->x - cur->x;
          lst.erase(next);
        }
      }
    } else {
      list<el>::iterator prev = cur;
      prev--;
      if (prev->c == 'L')
        cur = prev;
      else {
        if (cur->old > prev->old) {
          res[cur->idx] = cur->x - prev->x;
          lst.erase(cur);
          cur = prev;
        } else {
          res[prev->idx] = cur->x - prev->x;
          lst.erase(prev);
        }
      }
    }
  }
  for (int i = 1; i <= q; i++) printf("%d\n", res[i]);
  return 0;
}
