#C999. Net Population Change Queries

    ID: 54143 Type: Default 1000ms 256MiB

Net Population Change Queries

Net Population Change Queries

You are given data about the number of births and deaths over N years along with Q queries. Each query asks for the net population change (births minus deaths) between two years L and R (inclusive). Calculate the net population change for each query.

The net population change in the period \(L\) to \(R\) is defined as:

[ \text{Net Change} = \sum_{i=L}^{R} \text{births}[i] - \sum_{i=L}^{R} \text{deaths}[i] ]

Read the input from the standard input (stdin) and send the output to the standard output (stdout). For each query, print the answer on a new line.

inputFormat

The first line contains two integers N and Q, representing the number of years and the number of queries, respectively.

The second line contains N integers representing the number of births for each year.

The third line contains N integers representing the number of deaths for each year.

The next Q lines contain two integers per line, L and R, indicating the start and end years (0-indexed) for each query.

outputFormat

For each of the Q queries, output a single integer on a new line representing the net population change over the queried period.

## sample
5 3
2 3 4 1 5
1 2 1 3 4
0 2
1 3
0 4
5

2 4

</p>