#include <bits/stdc++.h>
using namespace std;
const long long N = 200001;
struct SegmentTree {
  vector<long long> t;
  SegmentTree() { t.assign(4 * N, 0); }
  void update(long long v, long long tl, long long tr, long long pos,
              long long new_val) {
    if (tl == tr) {
      t[v] = new_val;
    } else {
      long long tm = (tl + tr) / 2;
      if (pos <= tm)
        update(v * 2, tl, tm, pos, new_val);
      else
        update(v * 2 + 1, tm + 1, tr, pos, new_val);
      t[v] = max(t[v * 2], t[v * 2 + 1]);
    }
  }
  long long get_first(long long v, long long lv, long long rv, long long l,
                      long long r, long long x) {
    if (lv > r || rv < l) return -1;
    if (l <= lv && rv <= r) {
      if (t[v] <= x) return -1;
      while (lv != rv) {
        long long mid = lv + (rv - lv) / 2;
        if (t[2 * v] > x) {
          v = 2 * v;
          rv = mid;
        } else {
          v = 2 * v + 1;
          lv = mid + 1;
        }
      }
      return lv;
    }
    long long mid = lv + (rv - lv) / 2;
    long long rs = get_first(2 * v, lv, mid, l, r, x);
    if (rs != -1) return rs;
    return get_first(2 * v + 1, mid + 1, rv, l, r, x);
  }
  long long get_last(long long v, long long lv, long long rv, long long l,
                     long long r, long long x) {
    if (lv > r || rv < l) return -1;
    if (l <= lv && rv <= r) {
      if (t[v] <= x) return -1;
      while (lv != rv) {
        long long mid = lv + (rv - lv) / 2;
        if (t[2 * v + 1] > x) {
          v = 2 * v + 1;
          lv = mid + 1;
        } else {
          v = 2 * v;
          rv = mid;
        }
      }
      return rv;
    }
    long long mid = lv + (rv - lv) / 2;
    long long rs = get_last(2 * v + 1, mid + 1, rv, l, r, x);
    if (rs != -1) return rs;
    return get_last(2 * v, lv, mid, l, r, x);
  }
};
struct node {
  long long x, y;
  char d;
};
signed main() {
  long long t;
  t = 1;
  while (t--) {
    long long n, q;
    cin >> n >> q;
    vector<long long> cy;
    map<long long, long long> my, vis;
    vector<node> a(q);
    for (long long i = 0; i < q; ++i) {
      cin >> a[i].y >> a[i].x >> a[i].d;
      if (a[i].d == 'U') a[i].d = 'R';
      if (a[i].d == 'L') a[i].d = 'D';
      cy.push_back(a[i].y);
    }
    sort(cy.begin(), cy.end());
    unique(cy.begin(), cy.end());
    for (long long i = 0; i < cy.size(); ++i) {
      my[cy[i]] = i;
    }
    SegmentTree sd, sr;
    long long n1 = cy.size();
    for (long long i = 0; i < q; ++i) {
      if (a[i].d == 'D') {
        if (vis[a[i].y]) {
          cout << "0\n";
          continue;
        }
        vis[a[i].y] = 1;
        long long pos = my[a[i].y];
        long long z = sr.get_last(1, 0, n1 - 1, 0, pos, a[i].y - 1);
        if (z == -1) {
          cout << a[i].y << "\n";
          sd.update(1, 0, n1 - 1, pos, n);
        } else {
          cout << a[i].y - cy[z] << "\n";
          sd.update(1, 0, n1 - 1, pos, n - cy[z] + 1);
        }
      } else {
        if (vis[a[i].y]) {
          cout << "0\n";
          continue;
        }
        vis[a[i].y] = 1;
        long long pos = my[a[i].y];
        long long z = sd.get_first(1, 0, n1 - 1, pos, n1 - 1, n - a[i].y);
        if (z == -1) {
          cout << n + 1 - a[i].y << "\n";
          sr.update(1, 0, n1 - 1, pos, n);
        } else {
          cout << cy[z] - a[i].y << "\n";
          sr.update(1, 0, n1 - 1, pos, cy[z]);
        }
      }
    }
  }
}
