#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <utility>
#include <cmath>
#include <stdlib.h> 
#include <stdio.h>
#include <iterator>
#include <chrono>
#include <iomanip>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <deque>
#include <stack>
#include <queue>
#include <fstream>
#include <limits>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <sstream>
#include <random>
#include <cassert>

using namespace std;
#define ffor(n) for(int i = 0; i < n; i++)
#define fffor(n) for(int j = 0; j < n; j++)
int INF = 1e9 + 7;

vector <long long> offset;
long long nine_inv = 443664157, mod = 998244353;

struct node {
	long long val;
	int node_span, node_left, node_right, distance, lazy;
	node(long long _val, long long _distance, int _node_span, int _node_left, int _node_right, int _lazy) {
		val = _val;
		distance = _distance;
		node_span = _node_span;
		node_left = _node_left;
		node_right = _node_right;
		lazy = _lazy;
	}
};

void tree_update(vector <node>& tree, int a, int b, int delta, int current_node) {
	int node_left = tree[current_node].node_left, node_right = tree[current_node].node_right;
	if (a > node_right || node_left > b) return;
	else if (a <= node_left && node_right <= b) {
		tree[current_node].lazy = delta;
		tree[current_node].val = (((((offset[tree[current_node].distance] * delta) % mod) * nine_inv) % mod) * (offset[tree[current_node].node_span] - 1 + mod) % mod) % mod;
	}
	else {
		// push lazy updates
		if (tree[current_node].lazy != -1) {
			tree_update(tree, tree[2 * current_node].node_left, tree[2 * current_node].node_right, tree[current_node].lazy, 2 * current_node);
			tree_update(tree, tree[2 * current_node + 1].node_left, tree[2 * current_node + 1].node_right, tree[current_node].lazy, 2 * current_node + 1);
			tree[current_node].lazy = -1;
		}

		tree_update(tree, a, b, delta, 2 * current_node);
		tree_update(tree, a, b, delta, 2 * current_node + 1);
		tree[current_node].val = (tree[2 * current_node].val + tree[2 * current_node + 1].val) % mod;
	}
}


int main(void) {
	cin.tie(0); ios::sync_with_stdio(0);
	
	int n, q, n2 = 1, counter = 0;
	long long current_offset = 1;
	cin >> n >> q;

	while (n2 < n) n2 *= 2;
	vector <node> tree(2 * n2, node(0, 0, 0, 0, 0, -1));
	offset = vector <long long>(n + 1);
	for (int i = n2 - 1; i >= 0; i--) {
		tree[i + n2].node_left = i;
		tree[i + n2].node_right = i;
		tree[i + n2].node_span = 1;
	}
	for (int i = n - 1; i >= 0; i--) {
		tree[i + n2] = node(current_offset, counter, 1, i, i, -1);
		offset[counter] = current_offset;
		current_offset *= 10;
		current_offset %= mod;
		counter++;
	}
	offset.back() = current_offset;

	for (int i = n2 - 1; i >= 1; i--) {
		long long tempval = (tree[2 * i].val + tree[2 * i + 1].val) % mod;
		tree[i] = node(tempval, tree[2 * i + 1].distance, tree[2 * i].node_span + tree[2 * i + 1].node_span,
			tree[2 * i].node_left, tree[2 * i + 1].node_right, -1);
	}

	int l, r, delta;
	for (int i = 0; i < q; i++) {
		cin >> l >> r >> delta;
		l--; r--;
		tree_update(tree, l, r, delta, 1);
		cout << tree[1].val << '\n';
	}
}
	




/*
C:\Users\User\Desktop\comp_programming\final_straw_after_this_im_switching_to_vs_code\final_straw_after_this_im_switching_to_vs_code.cpp
*/

Measured memory_bytes: 21124