#include<bits/stdc++.h>
using namespace std;

double c[100][100];
double dp[100][100];//i??\??????j???????????¬
signed main() {
	int a, b;
	while(scanf("%d%d", &a, &b),a|b) {
		for (int d = 0; d < a; d++) {
			for (int e = 0; e < a; e++) {
				scanf("%lf", &c[d][e]);
			}
		}
		for (int d = 0; d < b; d++) {
			for (int e = 0; e < a; e++) {
				if (d == 0)dp[d][e] = 1;
				else dp[d][e] = -(1 << 15);
			}
		}
		for (int d = 0; d < a; d++)dp[0][d] = 1;
		for (int d = 1; d < b; d++) {
			for (int e = 0; e < a; e++) {//????????\
				for (int f = 0; f < a; f++) {//????????\
					dp[d][e] = max(dp[d][e], dp[d - 1][f] * c[f][e]);
				}
			}
		}
		double MAX = -(1 << 15);
		for (int d = 0; d < a; d++) {
			MAX = max(MAX, dp[b - 1][d]);
		}
		printf("%.10lf\n", MAX);
	}
}