#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

void func(int N,int M){

	double table[N+1][N+1],dp[M+1][N+1];

	for(int i = 0; i <= M; i++){
		for(int k = 0; k <= N; k++)dp[i][k] = 0.0;
	}

	for(int i = 1; i <= N; i++){
		for(int k = 1; k <= N; k++){
			scanf("%lf",&table[i][k]);
		}
	}

	for(int i = 1; i <= N; i++)dp[1][i] = 1.0;

	for(int i = 2; i <= M; i++){
		for(int k = 1; k <= N; k++){
			for(int p = 1; p <= N; p++){
				dp[i][k] = max(dp[i][k],dp[i-1][p]*table[p][k]);
			}
		}
	}

	double ans = -1.0;

	for(int i = 1; i <= N; i++){
		ans = max(ans,dp[M][i]);
	}

	printf("%.2lf\n",ans);

}

int main(){

	int N,M;
	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func(N,M);
	}

    return 0;
}