#include <bits/stdc++.h>
using namespace std;
int n, q;
int x, y, z;
int sum = 0;
map<int, pair<char, int> > ans;
map<int, pair<char, int> >::iterator t;
int main() {
  scanf("%d%d", &n, &q);
  ans[0] = {'U', 0};
  ans[n + 1] = {'L', 0};
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%c%c", &x, &y, &z, &z);
    t = ans.lower_bound(x);
    if (t->first == x) {
      printf("0\n");
      continue;
    }
    if (z == 'L') t--;
    sum = abs(x - t->first);
    if (t->second.first == z) sum += t->second.second;
    ans[x] = {z, sum};
    printf("%d\n", sum);
  }
}
