1556_E. Equilibrium_167
<image>

William has two arrays a and b, each consisting of n items.

For some segments l..r of these arrays William wants to know if it is possible to equalize the values of items in these segments using a balancing operation. Formally, the values are equalized if for each i from l to r holds a_i = b_i.

To perform a balancing operation an even number of indices must be selected, such that l ≤ pos_1 < pos_2 < ... < pos_k ≤ r. Next the items of array a at positions pos_1, pos_3, pos_5, ... get incremented by one and the items of array b at positions pos_2, pos_4, pos_6, ... get incremented by one.

William wants to find out if it is possible to equalize the values of elements in two arrays for each segment using some number of balancing operations, and what is the minimal number of operations required for that. Note that for each segment the operations are performed independently.

Input

The first line contains a two integers n and q (2 ≤ n ≤ 10^5, 1 ≤ q ≤ 10^5), the size of arrays a and b and the number of segments.

The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 10^9).

The third line contains n integers b_1, b_2, ..., b_n (0 ≤ b_i ≤ 10^9).

Each of the next q lines contains two integers l_i and r_i (1 ≤ l_i < r_i ≤ n), the edges of segments.

Output

For each segment output a single number — the minimal number of balancing operations needed or "-1" if it is impossible to equalize segments of arrays.

Example

Input


8 5
0 1 2 9 3 2 7 5
2 2 1 9 4 1 5 8
2 6
1 7
2 4
7 8
5 8


Output


1
3
1
-1
-1

Note

For the first segment from 2 to 6 you can do one operation with pos = [2, 3, 5, 6], after this operation the arrays will be: a = [0, 2, 2, 9, 4, 2, 7, 5], b = [2, 2, 2, 9, 4, 2, 5, 8]. Arrays are equal on a segment from 2 to 6 after this operation.

For the second segment from 1 to 7 you can do three following operations: 

  1. pos = [1, 3, 5, 6] 
  2. pos = [1, 7] 
  3. pos = [2, 7] 



After these operations, the arrays will be: a = [2, 2, 2, 9, 4, 2, 7, 5], b = [2, 2, 2, 9, 4, 2, 7, 8]. Arrays are equal on a segment from 1 to 7 after these operations.

For the third segment from 2 to 4 you can do one operation with pos = [2, 3], after the operation arrays will be: a = [0, 2, 2, 9, 3, 2, 7, 5], b = [2, 2, 2, 9, 4, 1, 5, 8]. Arrays are equal on a segment from 2 to 4 after this operation.

It is impossible to equalize the fourth and the fifth segment.

def naiveSolve():
    
    
    
    return



def solve():
    
    
    
    return

import math 
#MIN QUERIES
class RMQMIN(): #for MIN queries
    def __init__(self,arr):
        self.arr=arr
        MAXN=len(arr)
        K=int(math.log2(MAXN))+1
        self.lookup=[[0 for _ in range(K+1)] for __ in range(MAXN)]
        self.buildSparseTable()
    def buildSparseTable(self): 
        n=len(self.arr)
        for i in range(0,n):  
            self.lookup[i][0] = self.arr[i]  
        j=1
        while (1<<j)<=n:
            i=0
            while (i+(1<<j)-1)<n:
                self.lookup[i][j]=min(self.lookup[i][j-1],self.lookup[i+(1<<(j-1))][j-1])
                i += 1
            j += 1
    def query(self,L,R): #returns min on interval [l,r] inclusive
        j = int(math.log2(R-L+1))
        return min(self.lookup[L][j],self.lookup[R-(1<<j)+1][j])

class RMQMAX(): #for MAX queries
    def __init__(self,arr):
        self.arr=arr
        MAXN=len(arr)
        K=int(math.log2(MAXN))+1
        self.lookup=[[0 for _ in range(K+1)] for __ in range(MAXN)]
        self.buildSparseTable()
    def buildSparseTable(self): 
        n=len(self.arr)
        for i in range(0,n):  
            self.lookup[i][0] = self.arr[i]  
        j=1
        while (1<<j)<=n:
            i=0
            while (i+(1<<j)-1)<n:
                self.lookup[i][j]=max(self.lookup[i][j-1],self.lookup[i+(1<<(j-1))][j-1])
                i += 1
            j += 1
    def query(self,L,R): #returns min on interval [l,r] inclusive
        j = int(math.log2(R-L+1))
        return max(self.lookup[L][j],self.lookup[R-(1<<j)+1][j])

def main():
    
    n,q=readIntArr()
    a=readIntArr()
    b=readIntArr()
    for i in range(n):
        a[i]-=b[i]
    p=a.copy()
    for i in range(1,n):
        p[i]+=p[i-1]
    
    rmqMin=RMQMIN(p)
    rmqMax=RMQMAX(p)
    
    allans=[]
    for _ in range(q):
        l,r=readIntArr(); l-=1; r-=1
        total=p[r]
        if l-1>=0: total-=p[l-1]
        if total!=0:
            allans.append(-1)
            continue
        prefixMax=rmqMax.query(l,r)
        if l-1>=0: prefixMax-=p[l-1]
        if prefixMax>0:
            allans.append(-1)
            continue
        
        prefixMin=rmqMin.query(l,r)
        if l-1>=0: prefixMin-=p[l-1]
        allans.append(-prefixMin)
    multiLineArrayPrint(allans)
    
    return




import sys
input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
# input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.

def oneLineArrayPrint(arr):
    print(' '.join([str(x) for x in arr]))
def multiLineArrayPrint(arr):
    print('\n'.join([str(x) for x in arr]))
def multiLineArrayOfArraysPrint(arr):
    print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))
 
def readIntArr():
    return [int(x) for x in input().split()]
# def readFloatArr():
#     return [float(x) for x in input().split()]
 
def makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])
    dv=defaultValFactory;da=dimensionArr
    if len(da)==1:return [dv() for _ in range(da[0])]
    else:return [makeArr(dv,da[1:]) for _ in range(da[0])]
 
def queryInteractive(x):
    print('{}'.format(x))
    sys.stdout.flush()
    return int(input())
 
def answerInteractive(ans):
    print('! {}'.format(ans))
    sys.stdout.flush()
 
inf=float('inf')
# MOD=10**9+7
# MOD=998244353

from math import gcd,floor,ceil
# from math import floor,ceil # for Python2
 
for _abc in range(1):
    main()