Travelling Salesman

Jean is a travelling salesman. He keeps travelling among some cities. When he arrives in a city, he sells everything he has and buy new things. Then he travels to another city, sells his items and buy new ones. In this problem you will have to find the total amount of money Jean will gain on the optimal tour. On a tour he can go to some city more than once, and he must finish his tour in some cities. Also there is a starting city for his tour and the number of inter-city travels he wants to do in his tour. Input The input file contains several input sets. The description of each set is given below: Each set starts with four integers C (2 ≤ C ≤ 100), the number of cities, S (1 ≤ S ≤ 100), the identifier of the starting city, E (1 ≤ E ≤ 100), the number of cities his tour can end at, and T (1 ≤ T ≤ 1000), the number of inter-city travels he wants to do. Follow C lines with C non-negative integers. The j’th integer of the i’th line will describe the profit he earns when he goes from city i to city j. As he does not want to make a trip to a city he is already, the i’th integer of the i’th line will always be 0. Note that going from city i to city j can have a different profit than going from city j to city i. After there will be a line with E integers, the identifier of the cities he can end his tour. Input is terminated by a set where C = S = E = T = 0. This set should not be processed. There is a blank line beteween two input sets. Output For each input set produce one line of output, the total profit he can earn in the corresponding tour. Sample Input 3122 035 501 920 23 0000 Sample Output 7