#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <optional>
#include <utility>
#include <vector>
#include <atcoder/all>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif


constexpr int mod = 998244353;

int height = 0;
int length;
int sum_arr[1 << 20];
int value[1 << 20];
char belong[1 << 20];

void build(int n){
    height = 31 - __builtin_clz(n); if((length = (1 << height)) < n){ length *= 2; ++height; }

    for(int i = n - 1, v = 1; i >= 0; --i){ sum_arr[i + length] = v; v = 10LL * v % mod; }
    for(int i = length - 1; i > 0; --i){
        sum_arr[i] = sum_arr[2 * i] + sum_arr[2 * i + 1];
        if(sum_arr[i] >= mod) sum_arr[i] -= mod;
    }
    belong[1] = 1;
}

inline void propagate(int x){
    for(int shift = height; shift ; --shift){
        const int idx = x >> shift;
        if(belong[idx]){
            const int idx1 = 2 * idx, idx2 = idx1 + 1;
            belong[idx1] = belong[idx];
            belong[idx2] = belong[idx];
            value[idx] = static_cast<long long int>(sum_arr[idx]) * belong[idx] % mod;
            belong[idx] = 0;
        }
    }
    if(belong[x]){ value[x] = static_cast<long long int>(sum_arr[x]) * belong[x] % mod; belong[x] = 0; }
}

inline void calculateData(int x){
    while(x >>= 1){
        const int c1 = 2 * x, c2 = c1 + 1;
        const int a = belong[c1] ? static_cast<long long int>(sum_arr[c1]) * belong[c1] % mod : value[c1];
        const int b = belong[c2] ? static_cast<long long int>(sum_arr[c2]) * belong[c2] % mod : value[c2];
        value[x] = a + b; if(value[x] >= mod) value[x] -= mod;
    }
}

inline void update(int l, int r, char c){
    propagate(l += length); propagate(r += length - 1);
    for(int li = l, ri = r + 1; li < ri; li >>= 1, ri >>= 1){
        if(li & 1) belong[li++] = c;
        if(ri & 1) belong[--ri] = c;
    }
    calculateData(l); calculateData(r);
}

inline int sum_all(void){
    //propagate(2 * length - 1);
    return belong[1] ? static_cast<long long int>(sum_arr[1]) * belong[1] % mod : value[1];
}


void out(void){    
    for(int i = 1, l = 2; i < 16; ++i){
        if(i == l){ std::cout << '\n'; l *= 2;  }
        const int a = belong[i] ? static_cast<long long int>(sum_arr[i]) * belong[i] % mod : value[i];
        std::cout << a << ' ';
    } std::cout << '\n';
}

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int n, q; std::cin >> n >> q;
    build(n);

    while(q--){
        int l, r; char c; std::cin >> l >> r >> c; --l;
        update(l, r, c - '0');
        std::cout << sum_all() << '\n';
    }

    
    
    return 0;
}

Measured memory_bytes: 7492