Company: Motorq_29_dec
Difficulty: medium
Secret Recipe Problem Description There is a secret recipe with ingredients I 1 , I 2 , ..., I N . We do not know the quantities of each ingredient, but we have another sequence M 1 , M 2 , ..., M N-1 such that M j = I j + I j+1 for each valid i. You should process Q queries. In each query, you are given two indices u and v; your task is to compute I u + I v or determine that there is not enough information to uniquely determine this sum. Input: The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains two space-separated integers N and Q . The second line contains N-1 space-separated integers M 1 , M 2 , ..., M N-1 . Each of the following Q lines contains two space-separated integers u and v describing a query. Output: For each query, if it is impossible to determine the required sum, print a single line containing the string -1. Otherwise, print a single line containing