One of the first questions a subway traveler asks is: how much will the trip cost? Presenting this clearly should be simple, yet in practice it can mean looking up several tables posted around the station and then doing awkward arithmetic. Let's write a program that computes it instead.
We focus on a single subway line. You are given a price table stating how much a trip of $s$ stops costs, for each $s \ge 1$. You are also given the names of the stations in order, together with your starting and ending station. Compute the fare. Note that the line can be traveled in either direction, so only the number of stops between the two stations matters.
The first line contains the number $K$ of data sets. Each of the $K$ data sets has the following form.
The first line of a data set contains an integer $n$ ($2 \le n \le 50$), the number of stops on this line. The next $n - 1$ lines describe the price table: the $s$-th of these lines contains an integer, the price of traveling $s$ stops ($s = 1$ means getting off at the stop immediately after boarding). The next $n$ lines each contain the name of a station, listed in order along the line; every name consists of lowercase letters only and all names are distinct.
The last two lines contain the name of your starting station and the name of your ending station. Both appear in the station list and differ from each other.
For each data set, print the line Data Set x:, where x is the number of the data set (starting from 1), followed by a line containing the fare for the trip. Separate consecutive data sets with a single blank line.