n, q = map(int, input().split())

boxPos = list(map(int, input().split()))
weights = list(map(int, input().split()))

MOD = 10**9 + 7

for i in range(n):
    boxPos[i] -= i

for qta in range(q):
    x, y = map(int, input().split())
    if x < 0:
        x = - (x + 1)
        weights[x] = y
    else:
        x -= 1
        y -= 1
        ans = 10**100
        for cp in range(x, y + 1):
            convergeCost = 0
            for box in range(x, y + 1):
                convergeCost += weights[box] * abs(boxPos[box] - boxPos[cp])
            ans = min(ans, convergeCost)
        print(ans)


