#include <bits/stdc++.h>
using namespace std;
struct Comp {
  long long left, right, leftBorder, upBorder;
  bool isLeftVertical, isRightVertical;
};
class Solution {
 public:
  void solve(std::istream& in, std::ostream& out) {
    long long n;
    int q;
    in >> n >> q;
    map<int, Comp> components;
    set<int> eaten;
    components[1] = {1, n, 1, 1, true, false};
    while (q--) {
      char c;
      int x, y;
      in >> x >> y >> c;
      if (!eaten.insert(x).second) {
        out << "0\n";
        continue;
      }
      auto it = components.upper_bound(x);
      --it;
      Comp cur = it->second;
      components.erase(it);
      int res = 0;
      if (c == 'U') {
        if (cur.isRightVertical) {
          res = y - cur.upBorder + 1;
        } else {
          res = cur.right - x + 1;
        }
        if (x > cur.left) {
          components[cur.left] = {cur.left,           x - 1,
                                  cur.leftBorder,     cur.upBorder,
                                  cur.isLeftVertical, true};
        }
        if (x < cur.right) {
          components[x + 1] = {x + 1,        cur.right, x + 1,
                               cur.upBorder, true,      cur.isRightVertical};
        }
      } else {
        if (cur.isLeftVertical) {
          res = x - cur.left + 1;
        } else {
          res = x - cur.leftBorder + 1;
        }
        if (x > cur.left) {
          components[cur.left] = {cur.left,           x - 1,
                                  cur.leftBorder,     y + 1,
                                  cur.isLeftVertical, false};
        }
        if (x < cur.right) {
          components[x + 1] = {x + 1,        cur.right, cur.leftBorder,
                               cur.upBorder, false,     cur.isRightVertical};
        }
      }
      out << res << "\n";
    }
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
