#SGM0000020. Cân bằng (Equilibrium)

Cân bằng (Equilibrium)

Equilibrium

Source: Codeforces

Version: Phuoc Hung OJ Extended

You are given two arrays AA and BB of length NN. Each query segment [l,r][l,r] is processed independently.

One balancing operation selects an even number of positions:

l≤p1<p2<⋯<pk≤r.l\le p_1<p_2<\cdots<p_k\le r.

Then Ap1,Ap3,Ap5,…A_{p_1},A_{p_3},A_{p_5},\ldots are increased by 11, while Bp2,Bp4,Bp6,…B_{p_2},B_{p_4},B_{p_6},\ldots are increased by 11.

For each query, find the minimum number of operations needed to make Ai=BiA_i=B_i for all i∈[l,r]i\in[l,r], or print −1-1 if it is impossible.

Input

The first line contains N,QN,Q.

The second line contains A1,…,ANA_1,\ldots,A_N.

The third line contains B1,…,BNB_1,\ldots,B_N.

Each of the next QQ lines contains l,rl,r with l<rl<r.

Output

For every query, print the minimum number of operations, or −1-1 if impossible.

Subtasks

  • Subtask 1 — 20%: 2≤N≤502\le N\le 50, 1≤Q≤501\le Q\le 50, 0≤Ai,Bi≤10000\le A_i,B_i\le 1000.
  • Subtask 2 — 30%: 2≤N≤50002\le N\le 5000, 1≤Q≤50001\le Q\le 5000, 0≤Ai,Bi≤1090\le A_i,B_i\le 10^9.
  • Subtask 3 — 50%: 2≤N,Q≤1052\le N,Q\le 10^5, 0≤Ai,Bi≤1090\le A_i,B_i\le 10^9.

Examples

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

Explanation

The sample follows the operations exactly; each printed line corresponds to a query that requires output.