#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 300005;
const int MOD = 998244353;
ll c[MAX];
ll psc[MAX];
ll a_init[MAX];
struct SegNode {
  int l, r;
  ll sum_a_c;
  ll lazy;
} tree_nodes[4 * MAX];
int n, m;
ll safe(ll x, ll y) { return (x - y + MOD) % MOD; }
void build(int node, int l, int r) {
  tree_nodes[node].l = l;
  tree_nodes[node].r = r;
  tree_nodes[node].lazy = -1;
  if (l == r) {
    tree_nodes[node].sum_a_c = (a_init[l] % MOD) * c[l] % MOD;
    return;
  }
  int mid = (l + r) / 2;
  build(2 * node, l, mid);
  build(2 * node + 1, mid + 1, r);
  tree_nodes[node].sum_a_c =
      (tree_nodes[2 * node].sum_a_c + tree_nodes[2 * node + 1].sum_a_c) % MOD;
}
void pushdown(int node) {
  if (tree_nodes[node].lazy != -1) {
    ll x = tree_nodes[node].lazy;
    int left = 2 * node;
    int l_start = tree_nodes[left].l;
    int l_end = tree_nodes[left].r;
    ll sum_c_left = safe(psc[l_end], psc[l_start - 1]);
    tree_nodes[left].sum_a_c = (x % MOD) * sum_c_left % MOD;
    tree_nodes[left].lazy = x;
    int right = 2 * node + 1;
    int r_start = tree_nodes[right].l;
    int r_end = tree_nodes[right].r;
    ll sum_c_right = safe(psc[r_end], psc[r_start - 1]);
    tree_nodes[right].sum_a_c = (x % MOD) * sum_c_right % MOD;
    tree_nodes[right].lazy = x;
    tree_nodes[node].lazy = -1;
  }
}
void getrange(int node, int l, int r, ll x) {
  if (tree_nodes[node].l > r || tree_nodes[node].r < l)
    return;
  if (tree_nodes[node].l >= l && tree_nodes[node].r <= r) {
    ll sum_c = safe(psc[tree_nodes[node].r],
                        psc[tree_nodes[node].l - 1]);
    tree_nodes[node].sum_a_c = (x % MOD) * sum_c % MOD;
    tree_nodes[node].lazy = x;
    return;
  }
  pushdown(node);
  getrange(2 * node, l, r, x);
  getrange(2 * node + 1, l, r, x);
  tree_nodes[node].sum_a_c =
      (tree_nodes[2 * node].sum_a_c + tree_nodes[2 * node + 1].sum_a_c) % MOD;
}
ll query_sum(int node, int l, int r) {
  if (tree_nodes[node].l > r || tree_nodes[node].r < l)
    return 0;
  if (tree_nodes[node].l >= l && tree_nodes[node].r <= r) {
    return tree_nodes[node].sum_a_c;
  }
  pushdown(node);
  ll res = (query_sum(2 * node, l, r) + query_sum(2 * node + 1, l, r)) % MOD;
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    cin >> a_init[i];
  for (int i = 1; i <= n; i++) {
    c[i] = (1LL * i * (n - i + 1)) % MOD;
  }
  psc[0] = 0;
  for (int i = 1; i <= n; i++) {
    psc[i] = (psc[i - 1] + c[i]) % MOD;
  }
  build(1, 1, n);
  ll total = query_sum(1, 1, n);
  cout << total % MOD << "\n";
  for (int i = 0; i < m; i++) {
    int l, r;
    ll x;
    cin >> l >> r >> x;
    getrange(1, l, r, x % MOD);
    total = query_sum(1, 1, n);
    cout << total % MOD << "\n";
  }
}