#include <bits/stdc++.h>
using namespace std;
const int N = 200100, mod = 998244353;
inline void reduce(int& x) { x += x >> 31 & mod; }
long long sum[N];
int sum2[N];
int n, q, a[N], b[N], mx;
long long qry(int x) {
  long long ret = 0;
  for (; x; x -= x & -x) ret += sum[x];
  return ret;
}
int qry2(int x) {
  int ret = 0;
  for (; x; x -= x & -x) reduce(ret += sum2[x] - mod);
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (; (1 << mx) <= n; ++mx)
    ;
  --mx;
  for (int i = 1; i <= n; ++i) cin >> a[i], a[i] -= i;
  for (int i = 1; i <= n; ++i) cin >> b[i];
  for (int i = 1; i <= n; ++i) {
    sum[i] += b[i];
    sum2[i] = (sum2[i] + (long long)a[i] * b[i]) % mod;
    if (i + (i & -i) <= n)
      sum[i + (i & -i)] += sum[i], reduce(sum2[i + (i & -i)] += sum2[i] - mod);
  }
  for (int i = 1; i <= q; ++i) {
    int x, y;
    cin >> x >> y;
    if (x < 0) {
      x = -x;
      int delta = (long long)(y - b[x] - mod) * a[x] % mod;
      for (int j = x; j <= n; j += j & -j)
        sum[j] += y - b[x], reduce(sum2[j] += delta);
    } else {
      long long u = qry(x - 1), v = qry(y), w = u + (v - u + 1) / 2;
      int now = 0;
      for (int i = mx; ~i; --i)
        if (w > sum[now + (1 << i)]) w -= sum[now += 1 << i];
      int ans = (qry2(y) + qry2(x - 1) - 2 * qry2(now) -
                 (u + v - 2 * qry(now)) % mod * a[now + 1]) %
                mod;
      reduce(ans);
      cout << ans << '\n';
    }
  }
  return 0;
}
