#include <bits/stdc++.h>
using namespace std;
const int inf = 999999999;
struct seg_tree {
  int seg[4 * 200009], lazy[4 * 200009], flag;
  void construct_segtree(int start, int end, int pos) {
    lazy[pos] = -1;
    if (end == start + 1)
      seg[pos] = 0;
    else {
      int mid = (start + end) / 2;
      construct_segtree(start, mid, 2 * pos + 1);
      construct_segtree(mid, end, 2 * pos + 2);
      int t1 = seg[2 * pos + 1];
      int t2 = seg[2 * pos + 2];
      seg[pos] = max(t1, t2);
    }
  }
  int get_query(int ql, int qh, int low, int high, int pos) {
    if (lazy[pos] != -1) {
      seg[pos] = max(seg[pos], lazy[pos]);
      if (high != low + 1) {
        lazy[2 * pos + 1] = max(lazy[pos], lazy[2 * pos + 1]);
        lazy[2 * pos + 2] = max(lazy[pos], lazy[2 * pos + 2]);
      }
      lazy[pos] = -1;
    }
    if (qh <= low || ql >= high) return -1 * inf;
    if (low >= ql && high <= qh) return seg[pos];
    int mid = (low + high) / 2;
    return max(get_query(ql, qh, low, mid, 2 * pos + 1),
               get_query(ql, qh, mid, high, 2 * pos + 2));
  }
  void update(int ql, int qh, int low, int high, int val, int pos) {
    int mid = (high + low) / 2;
    if (lazy[pos] != -1) {
      seg[pos] = max(seg[pos], lazy[pos]);
      if (high != low + 1) {
        lazy[2 * pos + 1] = max(lazy[pos], lazy[2 * pos + 1]);
        lazy[2 * pos + 2] = max(lazy[pos], lazy[2 * pos + 2]);
      }
      lazy[pos] = -1;
    }
    if (qh <= low || ql >= high) return;
    if (low >= ql && high <= qh) {
      seg[pos] = max(val, seg[pos]);
      if (high != low + 1) {
        lazy[2 * pos + 1] = max(val, lazy[2 * pos + 1]);
        lazy[2 * pos + 2] = max(val, lazy[2 * pos + 2]);
      }
      return;
    }
    update(ql, qh, low, mid, val, 2 * pos + 1);
    update(ql, qh, mid, high, val, 2 * pos + 2);
    seg[pos] = max(seg[2 * pos + 1], seg[2 * pos + 2]);
    return;
  }
};
struct node {
  int first, second, dir, indx;
};
int compress(int arr[], int n);
int bin_search(int x, int arr[], int n);
int comp(node x, node y);
seg_tree row_tree, col_tree;
pair<int, int> query[200009];
int dir[200009];
int n, q, n_row, n_col, row_arr[200009], col_arr[200009];
int before[200009];
node sorted_query[200009];
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < q; i++) {
    int x, y;
    char d;
    scanf("%d %d %c", &x, &y, &d);
    row_arr[i] = y, col_arr[i] = x;
    query[i].first = x, query[i].second = y;
    if (d == 'U')
      dir[i] = 0;
    else
      dir[i] = 1;
    sorted_query[i].first = x, sorted_query[i].second = y;
    sorted_query[i].dir = dir[i], sorted_query[i].indx = i;
  }
  memset(before, 0, sizeof(before));
  sort(sorted_query, sorted_query + q, comp);
  node prev;
  for (int i = 0; i < q; i++) {
    if (i == 0)
      prev = sorted_query[i];
    else {
      int t1 = sorted_query[i].first == prev.first;
      int t2 = sorted_query[i].second == prev.second;
      int t3 = sorted_query[i].dir == prev.dir;
      if (t1 + t2 + t3 == 3)
        before[sorted_query[i].indx] = 1;
      else
        prev = sorted_query[i];
    }
  }
  n_row = compress(row_arr, q);
  n_col = compress(col_arr, q);
  row_tree.construct_segtree(0, n_row, 0);
  col_tree.construct_segtree(0, n_col, 0);
  for (int i = 0; i < q; i++) {
    if (before[i]) {
      printf("0\n");
      continue;
    }
    int row = query[i].second, col = query[i].first;
    int d = dir[i];
    if (d == 0) {
      int curr_col = bin_search(col, col_arr, n_col);
      int dest = col_tree.get_query(curr_col, curr_col + 1, 0, n_col, 0);
      printf("%d\n", row - dest);
      row_tree.update(bin_search(dest, row_arr, n_row),
                      bin_search(row, row_arr, n_row) + 1, 0, n_row, col, 0);
    } else {
      int curr_row = bin_search(row, row_arr, n_row);
      int dest = row_tree.get_query(curr_row, curr_row + 1, 0, n_row, 0);
      printf("%d\n", col - dest);
      col_tree.update(bin_search(dest, col_arr, n_col),
                      bin_search(col, col_arr, n_col) + 1, 0, n_col, row, 0);
    }
  }
  return 0;
}
int comp(node x, node y) {
  if (x.first == y.first && x.second == y.second && x.dir == y.dir)
    return x.indx < y.indx;
  if (x.first == y.first && x.second == y.second) return x.dir < y.dir;
  if (x.first == y.first) return x.second < y.second;
  return x.first < y.first;
}
int compress(int arr[], int n) {
  sort(arr, arr + n);
  int i = 0, j = 0, prev = -1;
  while (i < n) {
    if (prev != arr[i]) {
      prev = arr[i];
      arr[j++] = prev;
    }
    i++;
  }
  return j;
}
int bin_search(int x, int arr[], int n) {
  int s = 0, b = n - 1;
  while (b >= s) {
    int mid = (b + s) / 2;
    if (arr[mid] == x) return mid;
    if (arr[mid] > x)
      b = mid - 1;
    else
      s = mid + 1;
  }
  return -1;
}
