#!/usr/bin/env python3
import sys
from bisect import *


def rint():
    return map(int, sys.stdin.readline().split())


"""
 BIT : Binary Index Tree, Fenwick Tree

 level means power of 2, which is equal to lengh of items to be summed in fw_tree[i]
 01234567
 oxoxoxoxoxoxoxox : level 0
 ooxxooxxooxxooxx : level 1
 ooooxxxxooooxxxx : level 2
 ooooooooxxxxxxxx : level 3
"""
# start of BIT


def fw_level(i):
    i += 1
    return i&~i - 1


def fw_add(fwt, i, v):
    while i < n:
        fwt[i] += v
        i += 2**fw_level(i)


# get sum of values of items [0 ~ i] inclusive
def fw_get_sum(fwt, i):
    s = 0
    while i >= 0:
        s += fwt[i]
        i -= 2**fw_level(i)
    return s


# get sum of values of items [l ~ r]
def fw_get_sum_range(fwt, l, r):
    return fw_get_sum(fwt, r) - fw_get_sum(fwt, l-1)


def init_fw_tree(n):
    return [0]*n


# [l, r) range fw bisect
def fw_bisect(fwt, v, l, r):
    while l < r:
        mid = (l+r)//2
        if v < fw_get_sum(fwt, mid):
            r = mid
        else:
            l = mid+1
    return l

# end of BIT


#div version fw
div_val = 10**9 + 7


def fw_add_div(fwt, i, v):
    while i < n:
        fwt[i] += v
        if fwt[i] < 0:
            fwt[i] += ((-fwt[i])//div_val+1)*div_val
        fwt[i] %= div_val
        i += 2**fw_level(i)


def fw_get_sum_div(fwt, i):
    s = 0
    while i >= 0:
        s += fwt[i]
        s %= div_val
        i -= 2**fw_level(i)
    return s


def fw_get_sum_range_div(fwt, l, r):
    return fw_get_sum_div(fwt, r) - fw_get_sum_div(fwt, l-1)


def get_fixed_item_index(l, r):
    mid_sum =  fw_get_sum_range(fwt_w, l, r)/2
    #print("mid_sum : ", mid_sum)
    mid_sum += fw_get_sum(fwt_w, l-1)
    #print("mid_sum : ", mid_sum)
    return fw_bisect(fwt_w, mid_sum, l, r+1)


def find_min(l, r):
    min_sum = 0
    si = get_fixed_item_index(l,r)
    #print("si l r : ", si, l, r)
    # for i in range(l, si):
        # min_sum += w(i)*(a[si] - a[i] - 1 - (si - i - 1))
    #  min_sum += wsum(l, si-1)*(a[si] - si) + wai_sum(l,si-1)
    min_sum += (a[si] - si)*fw_get_sum_range(fwt_w, l, si-1) -  \
                fw_get_sum_range_div(fwt_awi, l, si-1)

    # for i in range(si+1, ri+1):
        # min_sum += w(i)*(a[i] - a[si] - 1 - (i - si - 1))
        # min_sum += w(i)*(a[i] - a[si] - 1 - (i - si - 1))
    # min_sum += wsum(si+1, r)*(si - a[si]) - wai_sum(si+1, r)
    min_sum += -(a[si]-si)*fw_get_sum_range(fwt_w, si+1, r) +  \
                fw_get_sum_range_div(fwt_awi, si+1, r)

    if min_sum < 0:
        min_sum += ((-min_sum)//div_val+1)*div_val

    return min_sum % div_val
    

def update_w(ni, nw):
    delta = nw - w[ni]
    w[ni] = nw
    fw_add(fwt_w, ni, delta)
    fw_add_div(fwt_awi, ni, delta*(a[ni]-ni))


n, q = rint()
a = list(rint())
w = list(rint())

fwt_w = init_fw_tree(n)
fwt_awi = init_fw_tree(n)

for i in range(n):
    fw_add(fwt_w, i, w[i])
for i in range(n):
    fw_add_div(fwt_awi, i,  w[i]*(a[i]-i))

for _ in range(q):
    x, y = rint()
    if x > 0:
        l = x-1 
        r = y-1
        #for i in range(n):
        #    print("sum until ", i, fw_get_sum(fwt_w, i))
        print(find_min(l, r))
    else:
        i = -x-1
        nw = y 
        update_w(i, nw)
