Given a directed and complete graph with vertices, and an initial vertex , compute the maximum cost of all the paths without repeated vertices that begin at . The given graph is represented by an matrix , where for every pair with , is the (perhaps negative) cost of the arc from to .
For instance, the maximum cost of the first test is 80, corresponding to the path , with cost .
Input consists of several cases, each one with the number of vertices , followed by the matrix ( lines, each one with integer numbers), followed by the initial vertex . Vertices are numbered from 0 to . You can assume , , that the diagonal has only zeros, and that the rest of numbers are between and .
For every case, print the cost of the worst path without repeated vertices that begins at .
Input
4 0 -10 30 90 -10 0 50 -12 -60 35 0 15 14 -70 -11 0 1 1 0 0 3 0 6 8 -4 0 3 -7 -2 0 2
Output
80 0 0