import java.lang.Math.abs
import java.util.*
import kotlin.math.max
import kotlin.math.min

// solution is at the bottom

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

fun main() {
    val (n, Q) = readIntArray(2)
    val tree = LongArray(4 * n)
    val upd = IntArray(4 * n)
    val MOD = 998244353L

    val power10 = LongArray(n + 1)
    power10[0] = 1
    for (i in 1..n) {
        power10[i] = (10 * power10[i - 1]) % MOD
    }

    val repeat = Array(n + 1) {LongArray(10)}
    for (i in 1..n) {
        for (d in 0..9) {
            repeat[i][d] = (10 * repeat[i - 1][d] + d) % MOD
        }
    }

    fun build(v: Int, left: Int, right: Int) {
        upd[v] = -1
        if (left == right) {
            tree[v] = 1
        } else {
            val mid = left + (right - left) / 2
            build(2 * v + 1, left, mid)
            build(2 * v + 2, mid + 1, right)
            tree[v] = (tree[2 * v + 2] + power10[right - (mid + 1) + 1] * tree[2*v + 1]) % MOD
        }
    }

    build(0, 0, n - 1)
    //println("debug: ${tree[0]}")

    fun push(v: Int, left: Int, right: Int) {
        if (upd[v] == -1) {
            return
        }

        upd[2*v + 1] = upd[v]
        upd[2*v + 2] = upd[v]

        val mid = left + (right - left) / 2

        tree[2*v + 1] = repeat[mid - left + 1][upd[v]]
        tree[2*v + 2] = repeat[right - (mid + 1) + 1][upd[v]]
        tree[v] = (tree[2 * v + 2] + power10[right - (mid + 1) + 1] * tree[2*v + 1]) % MOD
        upd[v] = -1
    }

    fun update(v: Int, left: Int, right: Int, queryLeft: Int, queryRight: Int, value: Int) {
        if (left == queryLeft && right == queryRight) {
            upd[v] = value
            tree[v] = repeat[right - left + 1][value]
        } else {
            push(v, left, right)
            val mid = left + (right - left) / 2
            if (queryRight <= mid) {
                update(2 * v + 1, left, mid, queryLeft, queryRight, value)
            } else if (queryLeft >= mid + 1) {
                update(2 * v + 2, mid + 1, right, queryLeft, queryRight, value)
            } else {
                update(2 * v + 1, left, mid, queryLeft, mid, value)
                update(2 * v + 2, mid + 1, right, mid + 1, queryRight, value)
            }

            tree[v] = (tree[2 * v + 2] + power10[right - (mid + 1) + 1] * tree[2*v + 1]) % MOD
        }
    }

    fun query(left: Int, right: Int, value: Int) {
        update(0, 0, n - 1, left, right, value)
        //println(tree[0])
    }

//    var v = 1
//    while (v < tree.size) {
//        println("$v, ${tree[v]}")
//        v *= 2
//    }

    for (q in 1..Q) {
        var (left, right, value) = readIntArray(3)
        left--
        right--
        query(left, right, value)
        println(tree[0])
    }
}

