#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, d;
} v[200010];
struct data1 {
  int max, po;
} f2[1000000];
struct data2 {
  int min, po;
} f1[1000000];
const int MAX = 1000000000;
int n, q, l[200010], r[200010], k, w[200010], t, back[200010];
bool b[200010];
char c;
int comp(node x, node y) { return x.l < y.l; }
void build(int l, int r, int k) {
  if (l == r) {
    f1[k].min = MAX;
    f1[k].po = MAX;
  } else {
    int mid = (l + r) / 2;
    build(l, mid, k * 2);
    build(mid + 1, r, k * 2 + 1);
    f1[k].min = MAX;
    f1[k].po = MAX;
  }
}
void pushdown1(int k) {
  if (f1[k].po != MAX) {
    f1[k * 2].min = min(f1[k * 2].min, f1[k].po);
    f1[k * 2 + 1].min = min(f1[k * 2 + 1].min, f1[k].po);
    f1[k * 2].po = min(f1[k * 2].po, f1[k].po);
    f1[k * 2 + 1].po = min(f1[k * 2 + 1].po, f1[k].po);
    f1[k].po = MAX;
  }
}
void pushdown2(int k) {
  if (f2[k].po) {
    f2[k * 2].po = max(f2[k * 2].po, f2[k].po);
    f2[k * 2 + 1].po = max(f2[k * 2 + 1].po, f2[k].po);
    f2[k * 2].max = max(f2[k * 2].max, f2[k].po);
    f2[k * 2 + 1].max = max(f2[k * 2 + 1].max, f2[k].po);
    f2[k].po = 0;
  }
}
void update1(int k) { f1[k].min = min(f1[k * 2].min, f1[k * 2 + 1].min); }
void update2(int k) { f2[k].max = max(f2[k * 2].max, f2[k * 2 + 1].max); }
int find1(int l, int r, int k, int t) {
  if (l == r) {
    return f1[k].min;
  } else {
    int mid = (l + r) / 2;
    pushdown1(k);
    if (t <= mid)
      return find1(l, mid, k * 2, t);
    else
      return find1(mid + 1, r, k * 2 + 1, t);
    update1(k);
  }
}
int find2(int l, int r, int k, int t) {
  if (l == r) {
    return f2[k].max;
  } else {
    int mid = (l + r) / 2;
    pushdown2(k);
    if (t <= mid)
      return find2(l, mid, k * 2, t);
    else
      return find2(mid + 1, r, k * 2 + 1, t);
    update2(k);
  }
}
void change2(int l, int r, int k, int ll, int rr, int t) {
  if (l == ll && r == rr) {
    f2[k].max = max(f2[k].max, t);
    f2[k].po = max(f2[k].po, t);
    return;
  } else {
    int mid = (l + r) / 2;
    pushdown2(k);
    if (rr <= mid)
      change2(l, mid, k * 2, ll, rr, t);
    else if (ll > mid)
      change2(mid + 1, r, k * 2 + 1, ll, rr, t);
    else {
      change2(l, mid, k * 2, ll, mid, t);
      change2(mid + 1, r, k * 2 + 1, mid + 1, rr, t);
    }
    update2(k);
  }
}
void change1(int l, int r, int k, int ll, int rr, int t) {
  if (l == ll && r == rr) {
    f1[k].min = min(f1[k].min, t);
    f1[k].po = min(f1[k].po, t);
  } else {
    int mid = (l + r) / 2;
    pushdown1(k);
    if (rr <= mid)
      change1(l, mid, k * 2, ll, rr, t);
    else if (ll > mid)
      change1(mid + 1, r, k * 2 + 1, ll, rr, t);
    else {
      change1(l, mid, k * 2, ll, mid, t);
      change1(mid + 1, r, k * 2 + 1, mid + 1, rr, t);
    }
    update1(k);
  }
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d%d", &l[i], &r[i]);
    c = getchar();
    if (c != 'U' && c != 'L') c = getchar();
    if (c == 'U')
      w[i] = 1;
    else
      w[i] = 2;
    v[i].l = l[i];
    v[i].d = i;
  }
  sort(v + 1, v + q + 1, comp);
  v[0].l = -1;
  for (int i = 1; i <= q; i++)
    if (v[i].l != v[i - 1].l) {
      t++;
      l[v[i].d] = t;
      back[t] = v[i].l;
    } else
      l[v[i].d] = t;
  build(1, t, 1);
  for (int i = 1; i <= q; i++)
    if (w[i] == 1) {
      if (b[l[i]]) {
        printf("%d\n", 0);
        continue;
      }
      b[l[i]] = 1;
      k = find1(1, t, 1, l[i]);
      if (k == MAX)
        printf("%d\n", r[i]);
      else
        printf("%d\n", r[i] - (n + 1 - back[k]));
      if (k != MAX)
        change2(1, t, 1, l[i], k, l[i]);
      else
        change2(1, t, 1, l[i], t, l[i]);
    } else {
      if (b[l[i]]) {
        printf("%d\n", 0);
        continue;
      }
      b[l[i]] = 1;
      k = find2(1, t, 1, l[i]);
      printf("%d\n", back[l[i]] - back[k]);
      if (k == 0)
        change1(1, t, 1, 1, l[i], l[i]);
      else
        change1(1, t, 1, k, l[i], l[i]);
    }
}
