#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:16777216")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using matrix = vector<vector<long long>>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pd;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define all(x) (x).begin(), (x).end()
//#define int ll

void FAST_IO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
    #ifdef _offline
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // _offline
}

const ll mod = 1e9 + 7;

struct dat {
    ll sumw, sumaw, lf, rg, len;

    dat() : sumw(0), sumaw(0), lf(0), rg(0), len(0) {};

    dat merge(const dat &other) const {
        dat res;
        res.sumw = sumw + other.sumw;
        if (res.sumw >= mod) {
            res.sumw -= mod;
        }
        res.sumaw = sumaw + other.sumaw;
        if (res.sumaw >= mod) {
            res.sumaw -= mod;
        }
        res.lf = (lf + sumw * other.len + other.lf) % mod;
        res.rg = (rg + other.rg + other.sumw * len) % mod;
        res.len = len + other.len;
        return res;
    }
};

const int MAXN = 2e5 + 100;
ll arr[MAXN];
ll t[MAXN * 4];
dat T[MAXN * 4];
int n;

void update(int v, int tl, int tr, int pos, ll w) {
    if (tl + 1 == tr) {
        t[v] = w;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos < tm) {
        update(v * 2 + 1, tl, tm, pos, w);
    }
    else {
        update(v * 2 + 2, tm, tr, pos, w);
    }
    t[v] = t[v * 2 + 1] + t[v * 2 + 2];
}

ll getsum(int v, int tl, int tr, int l, int r) {
    if (tl >= r || tr <= l) {
        return 0;
    }
    if (tl >= l && tr <= r) {
        return t[v];
    }
    int tm = (tl + tr) >> 1;
    ll a = getsum(v * 2 + 1, tl, tm, l, r);
    ll b = getsum(v * 2 + 2, tm, tr, l, r);
    return a + b;
}

int getpos(int l, int r) {
    ll sum = getsum(0, 0, n, l, r + 1);
    int lf = l, rg = r + 1, mid;
    while (lf + 1 < rg) {
        mid = (lf + rg) >> 1;
        ll cur = getsum(0, 0, n, l, mid + 1);
        if (cur * 2 <= sum) {
            lf = mid;
        }
        else {
            rg = mid;
        }
    }
    return (rg == r + 1 ? lf : rg);
}

void update2(int v, int tl, int tr, int pos, ll a, ll w) {
    if (tl + 1 == tr) {
        T[v].sumw = w;
        T[v].sumaw = (a * w) % mod;
        T[v].lf = w;
        T[v].rg = w;
        T[v].len = 1;
        return;
    }
    int tm = (tl + tr) >> 1;
    if (pos < tm) {
        update2(v * 2 + 1, tl, tm, pos, a, w);
    }
    else {
        update2(v * 2 + 2, tm, tr, pos, a, w);
    }
    T[v] = T[v * 2 + 1].merge(T[v * 2 + 2]);
}

dat get(int v, int tl, int tr, int l, int r) {
    if (tl >= r || tr <= l) {
        return dat();
    }
    if (tl >= l && tr <= r) {
        return T[v];
    }
    int tm = (tl + tr) >> 1;
    dat a = get(v * 2 + 1, tl, tm, l, r);
    dat b = get(v * 2 + 2, tm, tr, l, r);
    return a.merge(b);
}

signed main() {
    FAST_IO();
    int q;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    for (int i = 0; i < n; ++i) {
        ll w;
        cin >> w;
        update(0, 0, n, i, w);
        update2(0, 0, n, i, arr[i], w);
    }
    while (q--) {
        ll x, y;
        cin >> x >> y;
        if (x < 0) {
            update(0, 0, n, -x - 1, y);
            update2(0, 0, n, -x - 1, arr[-x - 1], y);
        }
        else {
            ll l = x - 1, r = y - 1;
            int pos = getpos(l, r);
            dat a = get(0, 0, n, l, pos);
            dat b = get(0, 0, n, pos + 1, r + 1);
            ll ans = 0;
            ans = (ans + arr[pos] * a.sumw) % mod;
            ans = (ans - a.sumaw + mod) % mod;
            ans = (ans - a.lf + mod) % mod;
            ans = (ans - arr[pos] * b.sumw + mod * mod) % mod;
            ans = (ans + b.sumaw + mod) % mod;
            ans = (ans - b.rg + mod) % mod;
            cout << ans << '\n';
        }
    }
}
