#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;


template<typename T> class Modular {
private:
  long long value;
  constexpr static int MOD() { return static_cast<int>(T::value); }
public:
  constexpr Modular() : value() {};
  constexpr Modular(const Modular& other) : value(other.value) {}
  template <typename U> constexpr Modular(const U& x) { value = normalize(x); }

  template <typename U> static long long normalize(const U& x) {
    long long v;
    if (-MOD() <= x && x < MOD()) v = static_cast<long long>(x);
    else v = static_cast<long long>(x % MOD());
    if (v < 0) v += MOD();
    return v;
  }

  constexpr static long long inverse(long long x) {
    x = (x % MOD() + MOD()) % MOD();
    long long y = MOD(), u = 1, v = 0;
    while(y) {
      long long t = x / y;
      x -= t * y; swap(x, y);
      u -= t * v; swap(u, v);
    }
    return (u % MOD() + MOD()) % MOD();
  }
  
  static long long mul(const long long& a, const long long& b) {
    long long res;
    #ifdef _WIN32
    unsigned long long x = a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm(
      "divl %4; \n\t"
      : "=a" (d), "=d" (m)
      : "d" (xh), "a" (xl), "r" (MOD())
    );
    res = m;
    #else
    res = a * b % MOD();
    #endif
    return res;
  }

  explicit operator long long() const noexcept { return value;}
  template <typename U> explicit operator U() const noexcept { return static_cast<U>(value); }

  constexpr Modular& operator=(const Modular& other) & noexcept { value = other.value; return *this; }
  template <typename U> constexpr Modular& operator=(const U& other) & noexcept { return *this = Modular(other); }

  constexpr Modular& operator+=(const Modular& other) noexcept { if ((value += other.value) >= MOD()) value -= MOD(); return *this; }
  template <typename U> constexpr Modular& operator+=(const U& other) noexcept { return *this += Modular(other); }

  constexpr Modular& operator-=(const Modular& other) noexcept { if ((value -= other.value) < 0) value += MOD(); return *this; }
  template <typename U> constexpr Modular& operator-=(const U& other) noexcept { return *this -= Modular(other); }

  constexpr Modular& operator*=(const Modular& other) noexcept { this->value = mul(this->value, other.value); return *this; }
  template <typename U> constexpr Modular& operator*=(const U& other) noexcept {return *this *= Modular(other); }

  constexpr Modular& operator/=(const Modular& other) noexcept { return *this *= Modular(inverse(other.value)); }
  template <typename U> constexpr Modular& operator/=(const U& other) noexcept { return *this *= Modular(inverse(normalize(other))); }

  constexpr Modular& operator++() noexcept {return *this += 1; }
  constexpr Modular operator++(int) noexcept { Modular ret(*this); *this += 1; return ret; }

  constexpr Modular& operator--() noexcept {return *this -= 1; }
  constexpr Modular operator--(int) noexcept { Modular ret(*this); *this -= 1; return ret; }

  constexpr Modular operator-() const { return Modular(-value); }

  friend constexpr bool operator==(const Modular& lhs, const Modular<T>& rhs) noexcept { return lhs.value == rhs.value; }
  template <typename U> friend constexpr bool operator==(const Modular<T>& lhs, U rhs) noexcept { return lhs == Modular<T>(rhs); }
  template <typename U> friend constexpr bool operator==(U lhs, const Modular<T>& rhs) noexcept { return Modular<T>(lhs) == rhs; }

  friend constexpr bool operator!=(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return !(lhs == rhs); }
  template <typename U> friend constexpr bool operator!=(const Modular<T>& lhs, U rhs) noexcept { return !(lhs == rhs); }
  template <typename U> friend constexpr bool operator!=(U lhs, const Modular<T> rhs) noexcept { return !(lhs == rhs); }

  friend constexpr bool operator<(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return lhs.value < rhs.value; }
  template <typename U> friend constexpr bool operator<(const Modular<T> &lhs, U rhs) noexcept { return lhs.value < rhs; }
  template <typename U> friend constexpr bool operator<(U lhs, const Modular<T> &rhs) noexcept { return lhs < rhs.value; }

  friend constexpr bool operator>(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return rhs.value < lhs.value; }
  template <typename U> friend constexpr bool operator>(const Modular<T> &lhs, U rhs) noexcept { return rhs.value < lhs; }
  template <typename U> friend constexpr bool operator>(U lhs, const Modular<T> &rhs) noexcept { return rhs < lhs.value; }

  friend constexpr bool operator<=(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return !(lhs.value > rhs.value); }
  template <typename U> friend constexpr bool operator<=(const Modular<T> &lhs, U rhs) noexcept { return !(lhs.value > rhs); }
  template <typename U> friend constexpr bool operator<=(U lhs, const Modular<T> &rhs) noexcept { return !(lhs < rhs.value); }

  friend constexpr bool operator>=(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return !(lhs.value < rhs.value); }
  template <typename U> friend constexpr bool operator>=(const Modular<T> &lhs, U rhs) noexcept { return !(lhs.value < rhs); }
  template <typename U> friend constexpr bool operator>=(U lhs, const Modular<T> &rhs) noexcept { return !(lhs < rhs.value); }

  friend constexpr Modular<T> operator+(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return Modular<T>(lhs) += rhs; }
  template <typename U> friend constexpr Modular<T> operator+(const Modular<T>& lhs, U rhs) noexcept { return Modular<T>(lhs) += rhs; }
  template <typename U> friend constexpr Modular<T> operator+(U lhs, const Modular<T> &rhs) noexcept { return Modular<T>(lhs) += rhs; }

  friend constexpr Modular<T> operator-(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return Modular<T>(lhs) -= rhs; }
  template <typename U> friend constexpr Modular<T> operator-(const Modular<T>& lhs, U rhs) noexcept { return Modular<T>(lhs) -= rhs; }
  template <typename U> friend constexpr Modular<T> operator-(U lhs, const Modular<T> &rhs) noexcept { return Modular<T>(lhs) -= rhs; }

  friend constexpr Modular<T> operator*(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return Modular<T>(lhs) *= rhs; }
  template <typename U> friend constexpr Modular<T> operator*(const Modular<T>& lhs, U rhs) noexcept { return Modular<T>(lhs) *= rhs; }
  template <typename U> friend constexpr Modular<T> operator*(U lhs, const Modular<T> &rhs) noexcept { return Modular<T>(lhs) *= rhs; }

  friend constexpr Modular<T> operator/(const Modular<T>& lhs, const Modular<T>& rhs) noexcept { return Modular<T>(lhs) /= rhs; }
  template <typename U> friend constexpr Modular<T> operator/(const Modular<T>& lhs, U rhs) noexcept { return Modular<T>(lhs) /= rhs; }
  template <typename U> friend constexpr Modular<T> operator/(U lhs, const Modular<T> &rhs) noexcept { return Modular<T>(lhs) /= rhs; }

  friend std::ostream& operator<<(std::ostream& stream, const Modular<T>& number) noexcept { return stream << number.value; }
  friend std::istream& operator>>(std::istream& stream, Modular<T>& number) { long long in; stream >> in; number.value = Modular<T>::normalize(in); return stream; }
  
  constexpr int getmod() const { return MOD(); }
};

template<typename T, typename U> Modular<T> power(const Modular<T>& x, const U& y) {
  assert(y >= 0);
  Modular<T> k = x, result = 1;
  U p = y;
  while (p > 0) {
    if (p & 1) result *= k;
    k *= k;
    p >>= 1;
  }
  return result;
}

template<typename T> class BinaryCoefficients {
private:
  vector<Modular<T>> fact_, inv_, finv_;
  long long MOD = static_cast<long long>(T::value);
public:
  constexpr BinaryCoefficients(int n = 2020200) : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
    for (int i = 2; i < n; i++) {
      fact_[i] = fact_[i - 1] * i;
      inv_[i] = -inv_[MOD % i] * (MOD / i);
      finv_[i] = finv_[i - 1] * inv_[i];
    }
  }
  constexpr Modular<T> comb(int n, int k) const noexcept { if (n < k || n < 0 || k < 0) return 0; return fact_[n] * finv_[k] * finv_[n - k]; }
  constexpr Modular<T> fact(int n) const noexcept { if (n < 0) return 0; return fact_[n]; }
  constexpr Modular<T> inv(int n) const noexcept { if (n < 0) return 0; return inv_[n]; }
  constexpr Modular<T> finv(int n) const noexcept { if (n < 0) return 0; return finv_[n]; }
};

//constexpr int mod = 1e9 + 7;
constexpr int mod = 998244353;
using mint = Modular<std::integral_constant<decay<decltype(mod)>::type, mod>>;
using bicoef = BinaryCoefficients<std::integral_constant<decay<decltype(mod)>::type, mod>>;

// struct modValue { static int value; };
// int modValue::value;
// int& mod = modValue::value;
// using mint = Modular<modValue>;
// using bicoef = BinaryCoefficients<modValue>;


// template <typename Monoid, typename LazyMonoid, typename FunctionMonoid, typename FunctionAction, typename FunctionLazy> class LazySegmentTree {
// private:
//   //using FunctionMonoid = function<Monoid(Monoid, Monoid)>;
//   //using FunctionAction = function<Monoid(Monoid, LazyMonoid)>;
//   //using FunctionLazy = function<LazyMonoid(LazyMonoid, LazyMonoid)>;
//   FunctionMonoid fm;
//   FunctionAction fa;
//   FunctionLazy fl;
//   int n, height;
//   vector<Monoid> data;
//   vector<LazyMonoid> lazy;
//   Monoid M_UNITY;
//   LazyMonoid L_UNITY;
//   void build (const int siz) {
//     n = 1;
//     height = 0;
//     while (n < siz) n <<= 1, ++height;
//     data.assign(2 * n, M_UNITY);
//     lazy.assign(2 * n, L_UNITY);
//   }
// public:
//   LazySegmentTree (const FunctionMonoid& f, const FunctionAction& g, const FunctionLazy& h, const Monoid& m_unity, const LazyMonoid& l_unity, int siz = 1) 
//   : fm(f), fa(g), fl(h), M_UNITY(m_unity), L_UNITY(l_unity) {
//     build(siz);
//   }
//   inline Monoid reflect (int k) {
//     return lazy[k] == L_UNITY ? data[k] : fa(data[k], lazy[k]);
//   }
//   inline void propagate (int k) {
//     if (lazy[k] == L_UNITY) return;
//     lazy[(k << 1) | 0] = fl(lazy[(k << 1) | 0], lazy[k]);
//     lazy[(k << 1) | 1] = fl(lazy[(k << 1) | 1], lazy[k]);
//     data[k] = reflect(k);
//     lazy[k] = L_UNITY;
//   }
//   inline void thrust (int k) {
//     for (int i = height; i > 0; --i) propagate(k >> i);
//   }
//   inline void recalc (int k) {
//     while (k >>= 1) data[k] = fm(reflect((k << 1) | 0), reflect((k << 1) | 1));
//   }
//   void modify (int left, int right, LazyMonoid val) {
//     thrust(left += n);
//     thrust(right += n - 1);
//     for (int l = left, r = right + 1; l < r; l >>= 1, r >>= 1) {
//       if (l & 1) lazy[l] = fl(lazy[l], val), l++;
//       if (r & 1) --r, lazy[r] = fl(lazy[r], val);
//     }
//     recalc(left);
//     recalc(right);
//   }
//   // void modify (int idx, LazyMonoid val) {
//   //   thrust(idx += n);
//   //   data[idx] = val;
//   //   lazy[idx] = L_UNITY;
//   //   recalc(idx);
//   // }
//   void modify (int idx, Monoid val) {
//     thrust(idx += n);
//     data[idx] = val;
//     lazy[idx] = L_UNITY;
//     recalc(idx);
//   }
//   Monoid get (int left, int right) {
//     thrust(left += n);
//     thrust(right += n - 1);
//     Monoid val_l = M_UNITY, val_r = M_UNITY;
//     for (int l = left, r = right + 1; l < r; l >>= 1, r >>= 1) {
//       if (l & 1) val_l = fm(val_l, reflect(l++));
//       if (r & 1) val_r = fm(reflect(--r), val_r);
//     }
//     return fm(val_l, val_r);
//   }
// };

template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  int n,height;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(F f,G g,H h,T ti,E ei):
    f(f),g(g),h(h),ti(ti),ei(ei){}
 
  void init(int n_){
    n=1;height=0;
    while(n<n_) n<<=1,height++;
    dat.assign(2*n,ti);
    laz.assign(2*n,ei);
  }
 
  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
 
  inline T reflect(int k){
    return laz[k]==ei?dat[k]:g(dat[k],laz[k]);
  }
 
  inline void propagate(int k){
    if(laz[k]==ei) return;
    laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
    laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
    dat[k]=reflect(k);
    laz[k]=ei;
  }
 
  inline void thrust(int k){
    for(int i=height;i;i--) propagate(k>>i);
  }
 
  inline void recalc(int k){
    while(k>>=1)
      dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
  }
 
  void update(int a,int b,E x){
    if(a>=b) return;
    thrust(a+=n);
    thrust(b+=n-1);
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
      if(l&1) laz[l]=h(laz[l],x),l++;
      if(r&1) --r,laz[r]=h(laz[r],x);
    }
    recalc(a);
    recalc(b);
  }
 
  void set_val(int a,T x){
    thrust(a+=n);
    dat[a]=x;laz[a]=ei;
    recalc(a);
  }
 
  T query(int a,int b){
    if(a>=b) return ti;
    thrust(a+=n);
    thrust(b+=n-1);
    T vl=ti,vr=ti;
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,reflect(l++));
      if(r&1) vr=f(reflect(--r),vr);
    }
    return f(vl,vr);
  }
 
  template<typename C>
  int find(int st,C &check,T &acc,int k,int l,int r){
    if(l+1==r){
      acc=f(acc,reflect(k));
      return check(acc)?k-n:-1;
    }
    propagate(k);
    int m=(l+r)>>1;
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);
    if(st<=l&&!check(f(acc,dat[k]))){
      acc=f(acc,dat[k]);
      return -1;
    }
    int vl=find(st,check,acc,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(st,check,acc,(k<<1)|1,m,r);
  }
 
  template<typename C>
  int find(int st,C &check){
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};

const int N = 202020;
pair<mint, int> table[10][N];
mint pow10[N];

function<pair<mint, int>(pair<mint, int>, pair<mint, int>)> f = [] (const pair<mint, int>& p, const pair<mint, int> q) {
  return make_pair(q.first + p.first * pow10[q.second], q.second + p.second);
};
function<pair<mint, int>(pair<mint, int>, int)> g = [] (const pair<mint, int>& p, int x) {
  if (x < 0) return p;
  return table[x][p.second];
};
function<int(int, int)> h = [] (int x, int y)  {
  return y;
};

signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, q;
  cin >> n >> q;
  using P = pair<mint, int>;
  pow10[0] = 1;
  for (int i = 0; i < n; i++) pow10[i + 1] = pow10[i] * 10;
  P ti(0,0);
  vector<vector<P>> dp(10,vector<P>(n+1));
  for(int d=1;d<10;d++){
    auto &vs=dp[d];
    vs[0]=ti;
    for(int i=0;i<n;i++) vs[i+1]=f(vs[i],P(d,1));
  }
  for (int d = 1; d < 10; d++) {
    table[d][0] = ti;
    for (int i = 1; i < n; i++) table[d][i] = f(table[d][i - 1], make_pair(mint(d), 1));
  }
  SegmentTree<pair<mint, int>, int> sgt(f, g, h, make_pair(mint(0), 0), -1);
  sgt.build(vector<pair<mint, int>>(n + 1, make_pair(mint(1), 1)));
  cerr << sgt.query(0, n).first << endl;
  for (int i = 0; i < q; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    sgt.update(l, r, d);
    cout << sgt.query(0, n).first << '\n';
  }
  return 0;
}

Measured memory_bytes: 77632