12474 - The Travelling Bard   

Description

Peter, a travelling bard, is commisioned by his king to visit N kingdoms.

Initially, Peter is at the S'th kingdom, and is about to travel to the N - 1 other kingdoms.

He knows how much time he needs to move to the y'th kingdom from the x'th kingdom, denoted as D[x][y].

Help him find out the minimum time he needs to visit all the other N - 1 kingdoms exactly once, and return to the S'th kingdom from the last foreign kingdom.

Input

The first line has two integers separated by a space, N and S.

Then N lines follow, the i'th line of which consists of N integers separted by a space.

The y'th number in the x'th line (among the last N lines) represents D[x][y].

1 < N <= 10

1 <= S <= N

0 <= D[x][y] < 100000

Output

The minimum total cost, followed by a newline character.

Sample Input  Download

Sample Output  Download

Tags

^ ^ 大家期中加油!!



Discuss