An equal sum partition of a sequence of numbers is a grouping of the numbers (in the same order as the original sequence) in such a way that each group has the same sum. For example, the sequence:
2\ 5\ 1\ 3\ 3\ 7
may be grouped as:
(2\ 5)\ (1\ 3\ 3)\ (7)
to yield an equal sum of .
Note: The partition that puts all the numbers in a single group is an equal sum partition with the sum equal to the sum of all the numbers in the sequence.
For this problem, you will write a program that takes as input a sequence of positive integers and returns the smallest sum for an equal sum partition of the sequence.
The first line contains the number of data sets that follow: (1 \leq p \leq 1000). The first line of each data set contains the data set number, followed by a space, followed by a decimal integer (1 \leq m \leq 10000), giving the total number of integers in the sequence. The remaining lines in the dataset consist of the values, per line, separated by a single space. The last line in the dataset may contain fewer than values.
For each data set, generate one line with the following values: the data set number as a decimal integer, a space, and the smallest sum for an equal sum partition of the sequence.
Example 1