#include <bits/stdc++.h>
using namespace std;
int n, m, first, second;
char w;
map<int, pair<int, int>> z;
int main() {
  cin >> n >> m;
  z[n + 1];
  while (m--) {
    cin >> first >> second >> w;
    auto i = *z.lower_bound(first);
    cout << (i.first - first
                 ? (w & 1 ? second - i.second.second : first - i.second.first)
                 : 0)
         << endl;
    if (i.first - first)
      z[first] = i.second,
      w & 1 ? z[i.first].first = first : z[first].second = second;
  }
}
