#include <bits/stdc++.h>
using namespace std;
int x[200005], y[200005];
char dir[200005][3];
int a[2 * 200005];
int lazyy[8 * 200005], lazyx[8 * 200005];
void build(int x, int l, int r) {
  if (l == r) {
    lazyx[x] = 0;
    lazyy[x] = 0;
    return;
  }
  build((x << 1), l, ((l + r) / 2));
  build(((x << 1) | 1), ((l + r) / 2) + 1, r);
  lazyy[x] = lazyx[x] = 0;
}
int query(int p, int x, int l, int r, int type) {
  if (l == r) {
    if (type == 0)
      return lazyx[x];
    else
      return lazyy[x];
  }
  lazyy[(x << 1)] = max(lazyy[(x << 1)], lazyy[x]);
  lazyy[((x << 1) | 1)] = max(lazyy[((x << 1) | 1)], lazyy[x]);
  lazyx[(x << 1)] = max(lazyx[(x << 1)], lazyx[x]);
  lazyx[((x << 1) | 1)] = max(lazyx[((x << 1) | 1)], lazyx[x]);
  lazyx[x] = lazyy[x] = 0;
  if (p <= ((l + r) / 2)) {
    return query(p, (x << 1), l, ((l + r) / 2), type);
  } else {
    return query(p, ((x << 1) | 1), ((l + r) / 2) + 1, r, type);
  }
}
void update(int L, int R, int x, int l, int r, int val, int type) {
  if (L <= l && r <= R) {
    if (type == 0) {
      lazyx[x] = max(lazyx[x], val);
    } else {
      lazyy[x] = max(lazyy[x], val);
    }
    return;
  }
  lazyy[(x << 1)] = max(lazyy[(x << 1)], lazyy[x]);
  lazyy[((x << 1) | 1)] = max(lazyy[((x << 1) | 1)], lazyy[x]);
  lazyx[(x << 1)] = max(lazyx[(x << 1)], lazyx[x]);
  lazyx[((x << 1) | 1)] = max(lazyx[((x << 1) | 1)], lazyx[x]);
  lazyx[x] = lazyy[x] = 0;
  if (L <= ((l + r) / 2)) {
    update(L, R, (x << 1), l, ((l + r) / 2), val, type);
  }
  if (((l + r) / 2) < R) {
    update(L, R, ((x << 1) | 1), ((l + r) / 2) + 1, r, val, type);
  }
}
int main() {
  int n, q;
  while (cin >> n >> q) {
    for (int i = 0; i < q; i++) {
      cin >> x[i] >> y[i];
      cin >> dir[i];
      a[i * 2] = x[i];
      a[i * 2 + 1] = y[i];
    }
    a[2 * q] = 0;
    sort(a, a + 2 * q + 1);
    int cnt = unique(a, a + 2 * q + 1) - a;
    build(1, 1, cnt);
    for (int i = 0; i < q; i++) {
      int _x = lower_bound(a, a + cnt, x[i]) - a + 1;
      int _y = lower_bound(a, a + cnt, y[i]) - a + 1;
      int ans;
      if (dir[i][0] == 'U') {
        ans = query(_x, 1, 1, cnt, 0);
        int _ans = lower_bound(a, a + cnt, ans) - a + 1;
        ans = y[i] - ans;
        update(_x, _x, 1, 1, cnt, y[i], 0);
        update(_ans, _y, 1, 1, cnt, x[i], 1);
      } else {
        ans = query(_y, 1, 1, cnt, 1);
        int _ans = lower_bound(a, a + cnt, ans) - a + 1;
        ans = x[i] - ans;
        update(_y, _y, 1, 1, cnt, x[i], 1);
        update(_ans, _x, 1, 1, cnt, y[i], 0);
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
