#include <bits/stdc++.h>
using namespace std;
struct meo {
  int x, y, x1, y1, p;
};
const int N = 200010;
int n, q, dir[N], X, Y;
meo a[N];
bool comparex(meo i, meo j) {
  if (i.x == j.x) {
    if (i.y == j.y)
      return i.p < j.p;
    else
      return i.y < j.y;
  }
  return i.x < j.x;
}
bool comparey(meo i, meo j) { return i.y < j.y; }
bool comparep(meo i, meo j) { return i.p < j.p; }
int T[2][8 * N] = {0}, F[2][8 * N] = {0}, res, L, R, v, x[N], y[N], fr[N] = {0};
void maximize(int c, int &i, int j) {
  if (c == 1) {
    if (a[j].x > a[i].x) i = j;
  } else if (a[j].y > a[i].y)
    i = j;
}
void Get(int c, int k, int l, int r) {
  if (l == r) {
    maximize(c, T[c][k], F[c][k]);
    F[c][k] = 0;
  } else if (F[c][k])
    maximize(c, F[c][k * 2], F[c][k]), maximize(c, F[c][k * 2 + 1], F[c][k]),
        F[c][k] = 0;
  if (l > r || v < l || v > r) return;
  if (l == r) {
    res = T[c][k];
    return;
  }
  int m = (l + r) >> 1;
  Get(c, k * 2, l, m);
  Get(c, k * 2 + 1, m + 1, r);
}
void Update(int c, int k, int l, int r) {
  if (l == r)
    maximize(c, T[c][k], F[c][k]), F[c][k] = 0;
  else if (F[c][k])
    maximize(c, F[c][k * 2], F[c][k]), maximize(c, F[c][k * 2 + 1], F[c][k]),
        F[c][k] = 0;
  if (l > r || l > R || r < L) return;
  if (L <= l && r <= R) {
    if (l == r)
      maximize(c, T[c][k], v);
    else
      maximize(c, F[c][k * 2], v), maximize(c, F[c][k * 2 + 1], v);
    return;
  }
  int m = (l + r) >> 1;
  Update(c, k * 2, l, m);
  Update(c, k * 2 + 1, m + 1, r);
}
int main(void) {
  scanf("%d%d", &n, &q);
  char c;
  for (int i = 1; i <= q; ++i) {
    scanf("%d%d", &a[i].y, &a[i].x);
    scanf("%c", &c);
    scanf("%c", &c);
    dir[i] = c == 'U';
    a[i].p = i;
  }
  a[0].x = a[0].y = a[0].x1 = a[0].y1 = 0;
  x[0] = y[0] = 0;
  sort(a + 1, a + 1 + q, comparex);
  for (int i = 1, cnt = 0, prev = 0; i <= q; ++i) {
    if (a[i].x == prev)
      a[i].x1 = cnt;
    else
      cnt++, a[i].x1 = cnt, prev = a[i].x, x[cnt] = a[i].x;
    if (a[i].x == a[i - 1].x && a[i].y == a[i - 1].y) fr[a[i].p] = 1;
  }
  X = a[q].x1;
  sort(a + 1, a + 1 + q, comparey);
  for (int i = 1, cnt = 0, prev = 0; i <= q; ++i)
    if (a[i].y == prev)
      a[i].y1 = cnt;
    else
      cnt++, a[i].y1 = cnt, prev = a[i].y, y[cnt] = a[i].y;
  Y = a[q].y1;
  sort(a + 1, a + 1 + q, comparep);
  for (int i = 1; i <= q; ++i) {
    if (fr[i]) {
      printf("0\n");
      continue;
    }
    res = 0;
    v = dir[i] * a[i].y1 + (1 - dir[i]) * a[i].x1;
    Get(dir[i], 1, 1, dir[i] * Y + (1 - dir[i]) * X);
    v = i;
    if (dir[i]) {
      printf("%d\n", n - a[i].y + 1 - x[a[res].x1]);
      L = a[res].x1 + 1;
      R = a[i].x1 - 1;
      if (L > R) continue;
      Update(0, 1, 1, X);
    } else {
      printf("%d\n", n - a[i].x + 1 - y[a[res].y1]);
      L = a[res].y1 + 1;
      R = a[i].y1 - 1;
      if (L > R) continue;
      Update(1, 1, 1, Y);
    }
  }
  return 0;
}
