As we know, Danny has a huge army and each time she wins a battle the size of her army is increased. Missandei, her advisor and Handmaiden, keeps the log of each battle and the amount and strength of soldiers won in a battle. 

Now, Danny has some questions for Missandei in which she asks the strength of the army gained during some battles. She will ask the query of the form $L, R$ and Missandei has to tell the strength gained in between the $L$ and $R$ battles. Help Missandei. 

You are given an array $A$, where $A[i]$ represents the number of soldiers won in $i^{th}$ battle and the strength of a soldier who was won in $i^{th}$ battle is given in another array $B[i]$. ( $B[i]$ represents the strength of each soldier who was won in the $i^{th}$ battle). 

------ Input: ------

First line will contain $N$ and $Q$, number of battles fought and number of queries. 
Next line contains $N$ space separated integers denoting the array $A$.
Next line contains $N$ space separated integers denoting the array $B$.
Next $Q$ lines contain two integers $L$ and $R$.

------ Output: ------
For each query, output the strength gained in between the $L$ and $R$ battles (both inclusive).

------ Constraints  ------
$1 ≤ N, Q ≤ 1000$
$0 ≤ A[i] ≤ 10^{6}$
$0 ≤ B[i] ≤ 10^{6}$
$1 ≤ L ≤ R ≤ N$

----- Sample Input 1 ------ 
5 3
2 3 1 6 5
1 2 3 4 5
2 3
1 1
1 5
----- Sample Output 1 ------ 
9
2
60
----- explanation 1 ------ 
For the first query, strength gained in $2^{nd}$ battle is $2*3 = 6$ and in $3^{rd}$ battle is $3*1 = 3$. Total = $6 + 3 = 9$.

Difficulty: EASY

Solutions:
(n, q) = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
for i in range(q):
	(a, b) = map(int, input().split())
	ans = 0
	for i in range(a - 1, b):
		k = list1[i] * list2[i]
		ans += k
	print(ans)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = 0
cum = [0]
for i in range(1, n + 1):
	s += a[i - 1] * b[i - 1]
	cum.append(s)
for i in range(q):
	(l, r) = map(int, input().split())
	print(cum[r] - cum[l - 1])


(N, Q) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for _ in range(Q):
	(L, R) = map(int, input().split())
	strength = 0
	for i in range(L, R + 1):
		strength += A[i - 1] * B[i - 1]
	print(strength)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for _ in range(q):
	c = 0
	(l, r) = map(int, input().split())
	for i in range(l - 1, r):
		c = c + a[i] * b[i]
	print(c)


(n, q) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for j in range(q):
	sum = 0
	(x, y) = list(map(int, input().split()))
	for i in range(x - 1, y):
		sum = sum + a[i] * b[i]
	print(sum)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
target = 0
for i in range(q):
	target = 0
	(l, r) = map(int, input().split())
	for j in range(l - 1, r):
		target += a[j] * b[j]
	print(target)


(n, q) = map(int, input().split())
arr1 = [int(x) for x in input().split()]
arr2 = [int(y) for y in input().split()]
for blah in range(q):
	(a, b) = map(int, input().split())
	(a, b) = (a - 1, b - 1)
	empt = []
	for p in range(a, b + 1):
		empt.append(arr1[p] * arr2[p])
	sum1 = 0
	for u in empt:
		sum1 += u
	print(sum1)


(n, q) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
for i in range(q):
	(l, r) = [int(i) for i in input().split()]
	s = 0
	for i in range(l - 1, r):
		s = s + a[i] * b[i]
	print(s)


(n, q) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
for i in range(q):
	ans = 0
	(x, y) = map(int, input().split())
	for k in range(x - 1, y):
		ans += l1[k] * l2[k]
	print(ans)


(n, q) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for j in range(q):
	(l, r) = list(map(int, input().split()))
	s = 0
	for k in range(l - 1, r):
		s = s + a[k] * b[k]
	print(s)


(n, q) = map(int, input().split())
a = list(map(int, input().split()[:n]))
b = list(map(int, input().split()[:n]))
l = []
for i in range(q):
	(c, d) = map(int, input().split())
	k = 0
	for j in range(c - 1, d):
		x = a[j] * b[j]
		k = k + x
	print(k)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [a[i] * b[i] for i in range(n)]
for i in range(q):
	(l, r) = map(int, input().split())
	print(sum(a[l - 1:r]))


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = []
for i in range(q):
	h = list(map(int, input().split()))
	l.append(h)
for i in range(q):
	ans = 0
	for j in range(l[i][0] - 1, l[i][1]):
		ans = ans + a[j] * b[j]
	print(ans)


(no_battele, query) = map(int, input().split())
no_of_soldiers = list(map(int, input().split()))
strength_of_soldiers = list(map(int, input().split()))
for i in range(query):
	ans = 0
	(s, e) = map(int, input().split())
	for i in range(s - 1, e):
		ans = ans + no_of_soldiers[i] * strength_of_soldiers[i]
	print(ans)


(n, q) = map(int, input().split())
l = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(q):
	(a, b) = map(int, input().split())
	if a == b:
		print(l[a - 1] * c[a - 1])
	else:
		s = 0
		for j in range(a - 1, b):
			s += l[j] * c[j]
		print(s)


(n, q) = map(int, input().split())
arra = list(map(int, input().split()))
arrb = list(map(int, input().split()))
for _ in range(q):
	(l, r) = map(int, input().split())
	sum = 0
	for i in range(l - 1, r):
		sum += arra[i] * arrb[i]
	print(sum)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(n):
	c.append(a[i] * b[i])
for i in range(q):
	(l, r) = map(int, input().split())
	if l == r:
		print(a[l - 1] * b[r - 1])
	else:
		d = c[l - 1:r]
		print(sum(d))


(n, q) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
for i in range(q):
	(a, b) = map(int, input().split())
	if a == b:
		print(l1[a - 1] * l2[b - 1])
	else:
		s = 0
		for j in range(a - 1, b):
			s += l1[j] * l2[j]
		print(s)


(n, p) = map(int, input().split())
l = list(map(int, input().split()))
l2 = list(map(int, input().split()))
for i in range(p):
	res = 0
	(x, y) = map(int, input().split())
	for j in range(x - 1, y):
		res += l[j] * l2[j]
	print(res)


(N, Q) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for j in range(Q):
	total = 0
	(L, R) = map(int, input().split())
	for k in range(L - 1, R):
		total += A[k] * B[k]
	print(total)


(n, q) = map(int, input().split())
array_a = list(map(int, input().split()))
array_b = list(map(int, input().split()))
for i in range(q):
	(l, r) = map(int, input().split())
	ans = 0
	for t in range(l - 1, r):
		ans += array_a[t] * array_b[t]
	print(ans)


(n, k) = map(int, input().split())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(k):
	(x, y) = map(int, input().split())
	g = 0
	for i in range(x - 1, y):
		g += b[i] * c[i]
	print(g)


(n, q) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for _ in range(q):
	r = 0
	(l, h) = map(int, input().split())
	for i in range(l - 1, h, 1):
		r += A[i] * B[i]
	print(r)


(n, q) = map(int, input().split())
arrA = [int(j) for j in input().split()]
arrB = [int(j) for j in input().split()]
product = []
for j in range(n):
	product.append(arrA[j] * arrB[j])
for j in range(q):
	(l, r) = map(int, input().split())
	print(sum(product[l - 1:r]))


(a, b) = map(int, input().split())
m = list(map(int, input().split()))
n = list(map(int, input().split()))
for i in range(b):
	res = 0
	(x, y) = map(int, input().split())
	for i in range(x - 1, y):
		res = res + m[i] * n[i]
	print(res)


n_battles = input().split(' ')
n_soilders = input().split(' ')
stegth = input().split(' ')
for i in range(int(n_battles[1])):
	battle_nums = input().split(' ')
	gain = 0
	for j in range(int(battle_nums[0]), int(battle_nums[1]) + 1):
		gain += int(stegth[j - 1]) * int(n_soilders[j - 1])
	print(gain)


(N, Q) = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
for i in range(Q):
	(a, b) = map(int, input().split(' '))
	j = a
	y = 0
	while a <= j <= b:
		x = A[j - 1] * B[j - 1]
		y += x
		j += 1
	print(y)


(n, q) = map(int, input().split())
l = list(map(int, input().split()))
m = list(map(int, input().split()))
for i in range(q):
	(a, b) = map(int, input().split())
	s = 0
	for i in range(a - 1, b):
		s += l[i] * m[i]
	print(s)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(q):
	(l, r) = map(int, input().split())
	o = 0
	while r != 0:
		if r >= l:
			o += a[r - 1] * b[r - 1]
		r -= 1
	print(o)


(n, q) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
for i in range(q):
	(l, r) = map(int, input().strip().split())
	count = 0
	for i in range(l - 1, r):
		count += a[i] * b[i]
	print(count)


(a, b) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for j in range(b):
	m = 0
	(o, p) = map(int, input().split())
	for i in range(o - 1, p):
		m += x[i] * y[i]
	print(m)


(n, q) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(q):
	(a, b) = map(int, input().split())
	z = 0
	j = a
	while j <= b:
		z += A[j - 1] * B[j - 1]
		j += 1
	print(z)


(battlecount, query) = map(int, input().split())
soldiers = list(map(int, input().split()))
strength = list(map(int, input().split()))
for i in range(query):
	(start, end) = map(int, input().split())
	sumstrength = 0
	j = start
	while j <= end:
		sumstrength = soldiers[j - 1] * strength[j - 1] + sumstrength
		j = j + 1
	print(sumstrength)


(a, b) = map(int, input().split(' '))
n = list(map(int, input().split(' ')))
m = list(map(int, input().split(' ')))
for j in range(b):
	(l, r) = map(int, input().split(' '))
	c = 0
	for k in range(l - 1, r):
		c = c + n[k] * m[k]
	print(c)


(n, q) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
for h in range(q):
	(c, d) = map(int, input().split())
	x = d - 1
	l = 0
	y = c - 1
	for m in range(y, d):
		l += a[m] * b[m]
	print(l)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(q):
	ans = 0
	tot = 0
	(l, r) = map(int, input().split())
	if l == r:
		tot = a[l - 1] * b[l - 1]
	else:
		for k in range(l, r + 1, 1):
			ans = a[k - 1] * b[k - 1]
			tot += ans
	print(tot)


arr = input().split()
n = int(arr[0])
q = int(arr[1])
soldiers = input().split()
strength = input().split()
for i in range(q):
	arr1 = input().split()
	l = int(arr1[0])
	r = int(arr1[1])
	a = l
	gain = 0
	for j in range(r - l + 1):
		gain += int(soldiers[a - 1]) * int(strength[a - 1])
		a += 1
	print(gain)


w = list(map(int, input().split(' ')))
n = w[0]
q = w[1]
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
for i in range(q):
	thing = list(map(int, input().split(' ')))
	first = thing[0] - 1
	second = thing[1] - 1
	total = 0
	for j in range(first, second + 1):
		total = total + a[j] * b[j]
	print(total)


(n, q) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = []
s = 0
for i in range(len(a)):
	s += a[i] * b[i]
	c.append(s)
for i in range(q):
	(l, r) = map(int, input().split())
	l = l - 2
	r = r - 1
	if l < 0:
		print(c[r])
	else:
		print(c[r] - c[l])


(N, Q) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for item in range(Q):
	(L, M) = map(int, input().split())
	total = 0
	for i in range(L - 1, M):
		total += A[i] * B[i]
	print(total)


(l, q) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(y) for y in input().split()]
for _ in range(q):
	(s, e) = map(int, input().split())
	ans = 0
	for i in range(s - 1, e):
		ans += a[i] * b[i]
	print(ans)


(n, q) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
for i in range(q):
	(l, r) = map(int, input().split())
	s = 0
	for j in range(l - 1, r):
		s += l1[j] * l2[j]
	print(s)


(n, q) = map(int, input().split())
ns = list(map(int, input().split()))
s = list(map(int, input().split()))
que = []
for i in range(q):
	(x, y) = map(int, input().split())
	que.append([x, y])
for i in que:
	l = i[0]
	r = i[1]
	su = 0
	for j in range(l, r + 1):
		su += ns[j - 1] * s[j - 1]
	print(su)