#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

const i64 NUM = 998244353LL;
const i64 inv_9 = 443664157LL;

i64 modpow(i64 a, i64 b) {
  i64 ans = 1;
  //cout << a << " " << b << endl;
  while(b != 0) {
    if(b % 2 == 1) {
      ans *= a;
      ans %= NUM;
    }
    a = a * a;
    a %= NUM;
    b /= 2;
  }
  return ans;
}

i64 modinv(i64 a) {
  return modpow(a, NUM-2);
}

struct SegTree {
  ///
  using value_type = long long;
  using index_type = vector<value_type>::size_type;
  static const value_type merge(const value_type &vl, const value_type &vr,
				index_type nl, index_type nc, index_type nr) {
    i64 d = modpow(10, nr - nc);
    i64 res = vl * d;
    res %= NUM;
    res += vr;
    res %= NUM;
    return res;
  }
  /*
  static const value_type update_elem(const value_type &current_value, const value_type &updated_value) {
    return updated_value;
  }
  */
  static const value_type update_lazy(const value_type &lazy_cur, const value_type &lazy_up) {
    return lazy_up;
  }
  static const value_type apply_lazy(const value_type &value, const value_type &lazy, i64 nl, i64 nr) {
    i64 d = modpow(10, nr - nl);
    d += NUM - 1;
    d %= NUM;

    d *= inv_9;
    d %= NUM;

    i64 val = (lazy * d) % NUM;
    return val;
  }
  const value_type default_value = 0;
  const value_type default_lazy = 0;
  ///

  vector<value_type> data, lazy;
  index_type n;
  
  SegTree(i64 n_) {
    i64 s = 1;
    while(s < n_) {
      s *= 2;
    }
    n = s;
    data.resize(s * 2 - 1, default_value);
    lazy.resize(s * 2 - 1, default_lazy);
  }

  value_type query(index_type l, index_type r, index_type nid, index_type nl, index_type nr) {
    lazy_eval(nid, nl, nr);
    if(nr <= l || r <= nl) {
      return default_value;
    }
    
    if(l <= nl && nr <= r) {
      return data[nid];
    }
    else {
      value_type vl = query(l, r, nid*2+1, nl, (nl+nr)/2);
      value_type vr = query(l, r, nid*2+2, (nl+nr)/2, nr);
      return merge(vl, vr, nl, (nl+nr)/2, nr);
    }
  }  
  value_type query(index_type l, index_type r) {
    return query(l, r, 0, 0, n);
  }

  /*
  void update(index_type i, value_type x) {
    i += n-1;
    data[i] = update_elem(data[i], x);
    while(i > 0) {
      i = (i - 1) / 2;
      data[i] = merge(data[i*2+1], data[i*2+2]);
    }
  }
  */

  void lazy_eval(index_type nid, index_type nl, index_type nr) {
    if(lazy[nid] != default_lazy) {
      data[nid] = apply_lazy(data[nid], lazy[nid], nl, nr);
      if(nr - nl > 1) {
	lazy[nid*2+1] = update_lazy(lazy[nid*2+1], lazy[nid]);
	lazy[nid*2+2] = update_lazy(lazy[nid*2+2], lazy[nid]);
      }
      lazy[nid] = default_lazy;
      //cout << "lazy " << nid << " " << data[nid] << " " << lazy[nid] << " " <<
      // nl << " " << nr << endl;
    }
  }
  
  void range_update(index_type l, index_type r, value_type x, index_type nid, index_type nl, index_type nr) {    
    lazy_eval(nid, nl, nr);    
    if(nr <= l || r <= nl) {
      return;
    }

    //cout << nid << " " << nl << " " << nr << endl;
    if(l <= nl && nr <= r) {      
      lazy[nid] = x;
      lazy_eval(nid, nl, nr);
    }
    else {
      range_update(l, r, x, nid*2+1, nl, (nl+nr)/2);
      range_update(l, r, x, nid*2+2, (nl+nr)/2, nr);
      data[nid] = merge(data[nid*2+1], data[nid*2+2], nl, (nl+nr)/2, nr);
    }
  }
  
  void range_update(index_type l, index_type r, value_type x) {
    range_update(l, r, x, 0, 0, n);
  }
};


int main(int argc, char *argv[]) {
  i64 N, Q, i;
  cin >> N >> Q;

  i64 N2 = 1;
  while(N2 < N) {
    N2 *= 2;
  }

  i64 delta = N2 - N;
  SegTree tree(N2);
  tree.range_update(delta, N2, 1);
  
  REP(0, Q, i) {
    i64 L, R, D;
    cin >> L >> R >> D;
    L--;
    tree.range_update(L + delta, R + delta, D);
    cout << tree.query(0, N2) << endl;
  }

  return 0;
}


Measured memory_bytes: 11460