ChonSu

No attempts yetTime limit1sMemory limit128 MB

Problem

The genealogy of a family can be represented as a rooted tree, in which each node corresponds to a member of the family and each edge connects a member to their parent. The root is the founder of the family and has no parent in the genealogy; leaf nodes correspond to members with no children.

The distance between two members in a genealogy is called a ChonSu in Korea, and it is defined as the number of edges on the path between them. For example, in the genealogy shown below, the ChonSu between persons 1 and 3 is 3, while the ChonSu between persons 1 and 5 is 5. From now on, the ChonSu between person ii and person jj is written ChonSu(i, j).

Example genealogy

A rooted tree in which every node that is not a leaf has exactly two children is called a 2-tree. In other words, a 2-tree is a binary tree in which each node has either two children or none. The tree shown above is a 2-tree.

Consider a family whose complete genealogy is unknown. What is known is that the genealogy is a 2-tree with nn leaf nodes. Assume the leaf nodes are numbered 1,2,,n1, 2, \ldots, n from left to right as in the figure. Also known is the ChonSu between every pair of leaf nodes whose numbers are consecutive; that is, ChonSu(i, i+1) is known for every ii (1in11 \le i \le n-1).

It is well known that this information alone is enough to compute the ChonSu between any two leaf nodes.

Write a program that, given two leaf members xx and yy (1x<yn1 \le x < y \le n), computes ChonSu(x, y).

For the figure above you are given n=6n = 6, ChonSu(1, 2) = 3, ChonSu(2, 3) = 2, ChonSu(3, 4) = 5, ChonSu(4, 5) = 3, and ChonSu(5, 6) = 2, and from this you can compute ChonSu(1, 6), the ChonSu between x=1x = 1 and y=6y = 6.

Input

The input consists of several test cases. The first line contains the number of test cases TT. For each test case, the first line contains an integer nn (3n10003 \le n \le 1000), the number of leaf nodes. The next line contains n1n-1 integers ChonSu(1, 2), ChonSu(2, 3), ..., ChonSu(n-1, n) in order. The last line contains two integers xx and yy (1x<yn1 \le x < y \le n), the numbers of the two leaf members whose ChonSu is to be computed.

Output

For each test case, print exactly one line containing a single integer: the ChonSu between the two leaf nodes xx and yy.