#include <bits/stdc++.h>
using namespace std;
const int maxq = 200005;
int ans, x, y, neo;
int n, q, a, b, sizedesu;
char c;
struct node {
  int l, r, Mw, lz, mw;
} allcl[maxq * 4], allcu[maxq * 4];
set<int> checkpie;
vector<int> allpie;
pair<int, char> allcmd[maxq];
void buildl(int l, int r, int k) {
  allcl[k].l = l;
  allcl[k].r = r;
  allcl[k].mw = 0;
  allcl[k].Mw = 0;
  allcl[k].lz = 0;
  if (l + 1 == r) return;
  int m = (l + r) / 2;
  buildl(l, m, 2 * k);
  buildl(m, r, 2 * k + 1);
}
void getlm(int k) {
  if (allcl[k].mw == allcl[k].Mw) {
    ans = allcl[k].mw;
    return;
  }
  int l = allcl[k].l, r = allcl[k].r;
  int m = (l + r) / 2;
  if (allcl[k].lz) {
    allcl[k].lz = 0;
    allcl[2 * k].lz = m - l - 1;
    allcl[2 * k + 1].mw = allcl[2 * k].mw = allcl[k].mw;
    allcl[2 * k + 1].lz = r - m - 1;
    allcl[2 * k + 1].Mw = allcl[2 * k].Mw = allcl[k].Mw;
  }
  if (x <= allpie[m])
    getlm(2 * k);
  else
    getlm(2 * k + 1);
}
void changelm(int l, int r, int k) {
  if (allcl[k].mw >= neo) return;
  if (neo > allcl[k].Mw && allpie[l] >= x && allpie[r] <= y) {
    allcl[k].Mw = allcl[k].mw = neo;
    allcl[k].lz = r - l - 1;
    return;
  } else if (l + 1 == r)
    return;
  int m = (l + r) / 2;
  if (allcl[k].lz) {
    allcl[k].lz = 0;
    allcl[2 * k].lz = m - l - 1;
    allcl[2 * k + 1].mw = allcl[2 * k].mw = allcl[k].mw;
    allcl[2 * k + 1].Mw = allcl[2 * k].Mw = allcl[k].Mw;
    allcl[2 * k + 1].lz = r - m - 1;
  }
  if (x < allpie[m]) changelm(l, m, 2 * k);
  if (y > allpie[m]) changelm(m, r, 2 * k + 1);
  allcl[k].mw = min(allcl[2 * k].mw, allcl[2 * k + 1].mw);
  allcl[k].Mw = max(allcl[2 * k].Mw, allcl[2 * k + 1].Mw);
}
void buildu(int l, int r, int k) {
  allcu[k].l = l;
  allcu[k].r = r;
  allcu[k].Mw = allcu[k].mw = n + 1;
  allcu[k].lz = 0;
  if (l + 1 == r) return;
  int m = (l + r) / 2;
  buildu(l, m, 2 * k);
  buildu(m, r, 2 * k + 1);
}
void getum(int k) {
  if (allcu[k].mw == allcu[k].Mw) {
    ans = allcu[k].mw;
    return;
  }
  int l = allcu[k].l, r = allcu[k].r;
  int m = (l + r) / 2;
  if (allcu[k].lz) {
    allcu[k].lz = 0;
    allcu[2 * k].lz = m - l - 1;
    allcu[2 * k + 1].mw = allcu[2 * k].mw = allcu[k].mw;
    allcu[2 * k + 1].lz = r - m - 1;
    allcu[2 * k + 1].Mw = allcu[2 * k].Mw = allcu[k].Mw;
  }
  if (x <= allpie[m])
    getum(2 * k);
  else
    getum(2 * k + 1);
}
void changeum(int l, int r, int k) {
  if (allcu[k].Mw <= neo) return;
  if (neo < allcu[k].mw && allpie[l] >= x && allpie[r] <= y) {
    allcu[k].Mw = allcu[k].mw = neo;
    allcu[k].lz = r - l - 1;
    return;
  } else if (l + 1 == r)
    return;
  int m = (l + r) / 2;
  if (allcu[k].lz) {
    allcu[k].lz = 0;
    allcu[2 * k].lz = m - l - 1;
    allcu[2 * k + 1].mw = allcu[2 * k].mw = allcu[k].mw;
    allcu[2 * k + 1].Mw = allcu[2 * k].Mw = allcu[k].Mw;
    allcu[2 * k + 1].lz = r - m - 1;
  }
  if (x < allpie[m]) changeum(l, m, 2 * k);
  if (y > allpie[m]) changeum(m, r, 2 * k + 1);
  allcu[k].mw = min(allcu[2 * k].mw, allcu[2 * k + 1].mw);
  allcu[k].Mw = max(allcu[2 * k].Mw, allcu[2 * k + 1].Mw);
}
int main(int argc, char *argv[]) {
  scanf("%d%d", &n, &q);
  allpie.push_back(0);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &a, &b);
    getchar();
    c = getchar();
    allpie.push_back(a);
    allcmd[i] = make_pair(a, c);
  }
  allpie.push_back(n + 1);
  sort(allpie.begin(), allpie.end());
  allpie.erase(unique(allpie.begin(), allpie.end()), allpie.end());
  sizedesu = allpie.size() - 1;
  buildl(0, sizedesu, 1);
  buildu(0, sizedesu, 1);
  for (int i = 0; i < q; i++) {
    x = allcmd[i].first;
    if (checkpie.count(x) == 0) {
      checkpie.insert(x);
      switch (allcmd[i].second) {
        case 'L':
          getlm(1);
          printf("%d\n", x - ans);
          neo = x;
          y = x;
          x = ans;
          changeum(0, sizedesu, 1);
          break;
        case 'U':
          getum(1);
          printf("%d\n", ans - x);
          neo = x;
          y = ans;
          changelm(0, sizedesu, 1);
          break;
      }
    } else
      printf("0\n");
  }
  return 0;
}
