#include <bits/stdc++.h>
using namespace std;
struct query {
  int x, height, tab;
};
int max(int a, int b) {
  if (a < b)
    return b;
  else
    return a;
}
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int maxTree[2][1200000];
int getmax(int tab, int id, int lb, int ub, int cell) {
  if (lb == cell and ub == cell + 1)
    return maxTree[tab][id];
  else if ((lb + ub) / 2 > cell)
    return max(maxTree[tab][id],
               getmax(tab, 2 * id + 1, lb, (lb + ub) / 2, cell));
  else
    return max(maxTree[tab][id],
               getmax(tab, 2 * id + 2, (lb + ub) / 2, ub, cell));
}
void setmax(int tab, int id, int lb, int ub, int mlb, int mub, int val) {
  if (maxTree[tab][id] >= val) return;
  if (lb == mlb and ub == mub) {
    maxTree[tab][id] = val;
    return;
  }
  if (mlb < (lb + ub) / 2)
    setmax(tab, 2 * id + 1, lb, (lb + ub) / 2, mlb, min(mub, (lb + ub) / 2),
           val);
  if (mub > (lb + ub) / 2)
    setmax(tab, 2 * id + 2, (lb + ub) / 2, ub, max(mlb, (lb + ub) / 2), mub,
           val);
}
int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  int pow2 = 1;
  while (pow2 < 2 * q + 2) pow2 *= 2;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2 * pow2; j++) maxTree[i][j] = 0;
  }
  query tabQ[q];
  int x, height, tab;
  string dir;
  int m;
  vector<int> keys(2 * q + 2);
  unordered_map<int, int> assoc;
  for (int i = 0; i < q; i++) {
    cin >> x >> height >> dir;
    x--;
    height--;
    if (dir[0] == 'U') {
      tab = 0;
    } else {
      tab = 1;
      swap(x, height);
    }
    tabQ[i].x = x;
    tabQ[i].height = height;
    tabQ[i].tab = tab;
    keys[2 * i] = x;
    keys[2 * i + 1] = height;
  }
  keys[2 * q] = -1;
  keys[2 * q + 1] = 0;
  sort(keys.begin(), keys.end());
  assoc[keys[0]] = 0;
  int cnt = 1;
  for (int i = 1; i < keys.size(); i++) {
    if (keys[i] != keys[i - 1]) {
      assoc[keys[i]] = cnt;
      cnt++;
    }
  }
  for (int i = 0; i < q; i++) {
    m = getmax(tabQ[i].tab, 0, 0, pow2, assoc[tabQ[i].x]);
    printf("%d\n", tabQ[i].height - m + 1);
    setmax(tabQ[i].tab, 0, 0, pow2, assoc[tabQ[i].x], assoc[tabQ[i].x] + 1,
           tabQ[i].height + 1);
    if (m < tabQ[i].height + 1) {
      setmax(1 - tabQ[i].tab, 0, 0, pow2, assoc[m - 1] + 1,
             assoc[tabQ[i].height] + 1, tabQ[i].x + 1);
    }
  }
  return 0;
}
