#include <bits/stdc++.h>
using namespace std;
string tree[4 * 200010];
char lazy[4 * 200010];
string combine(const string &l, const string &r) { return l + r; }
void build(int node, int start, int end) {
  if (start == end)
    tree[node] = "1";
  else {
    int mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    tree[node] = combine(tree[2 * node], tree[2 * node + 1]);
  }
}
void updaterange(int node, int start, int end, int l, int r, char val) {
  if (lazy[node] != '\0') {
    tree[node] = string((end - start + 1), lazy[node]);
    if (start != end) {
      lazy[node * 2] = lazy[node];
      lazy[node * 2 + 1] = lazy[node];
    }
    lazy[node] = '\0';
  }
  if (start > end || start > r || end < l) return;
  if (start >= l && end <= r) {
    tree[node] = string((end - start + 1), val);
    if (start != end) {
      lazy[node * 2] = val;
      lazy[node * 2 + 1] = val;
    }
    return;
  }
  long long mid = (start + end) / 2;
  updaterange(2 * node, start, mid, l, r, val);
  updaterange(2 * node + 1, mid + 1, end, l, r, val);
  tree[node] = combine(tree[2 * node], tree[2 * node + 1]);
}
string queryrange(int node, int start, int end, int l, int r) {
  if (lazy[node] != '\0') {
    tree[node] = string((end - start + 1), lazy[node]);
    if (start != end) {
      lazy[node * 2] = lazy[node];
      lazy[node * 2 + 1] = lazy[node];
    }
    if (start != end) {
      lazy[node * 2] = lazy[node];
      lazy[node * 2 + 1] = lazy[node];
    }
    lazy[node] = '\0';
  }
  if (start > end || start > r || end < l) {
    return 0;
  }
  if (start >= l && end <= r) return tree[node];
  int mid = (start + end) / 2;
  return combine(queryrange(2 * node, start, mid, l, r),
                 queryrange(2 * node + 1, mid + 1, end, l, r));
}
void solve() {
  memset(lazy, '\0', sizeof(lazy));
  ;
  int n, q;
  cin >> n >> q;
  build(1, 1, n);
  while (q--) {
    int l, r;
    char d;
    cin >> l >> r >> d;
    updaterange(1, 1, n, l, r, d);
    string ans = queryrange(1, 1, n, 1, n);
    int a = 0;
    for (int i = 0; i < ans.size(); i++) {
      a = ((a * 10) % 998244353 + (ans[i] - '0')) % 998244353;
    }
    cout << a << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  for (int I = 1; I <= t; I++) {
    solve();
  }
  return 0;
}
