#K64657. Analyze Performance

    ID: 32024 Type: Default 1000ms 256MiB

Analyze Performance

Analyze Performance

In this problem, you are given the number of days Arya practiced archery. Two arrays are provided: one representing the number of arrows shot on each day and another representing the total score obtained on that day. You are also given a series of queries. Each query consists of two integers, L and R, representing a range of days. For each query, you need to calculate:

$$\text{totalArrows} = \sum_{i=L}^{R} A_i$$

and

$$\text{totalScore} = \sum_{i=L}^{R} B_i$$

Your task is to process all queries and output the results. Input is read from standard input and the output should be printed to standard output.

inputFormat

The first line contains two integers N and Q, where N is the number of days and Q is the number of queries.

The second line contains N space-separated integers representing the array A (number of arrows shot each day).

The third line contains N space-separated integers representing the array B (score obtained each day).

The next Q lines each contain two integers L and R which represent a query.

outputFormat

For each query, output a single line with two integers: the total number of arrows shot and the total score obtained in the given range.

## sample
5 2
10 5 15 20 25
100 50 150 200 250
1 3
2 5
30 300

65 650

</p>