#include<stdio.h>
double dp[2][100];
double ch[100][100];
double max(double a,double b){return a>b?a:b;}
int main(){
	int n,m;
	int i,j,k;
	while(1){
	scanf("%d %d",&n,&m);
	if(n==0)return 0;
	for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%lf",&ch[i][j]);
	for(i=0;i<n;i++)dp[0][i]=1.0f;
	for(i=1;i<m;i++){
		for(j=0;j<n;j++){
			dp[i%2][j]=0.0f;
			for(k=0;k<n;k++)dp[i%2][j]=max(dp[i%2][j],dp[(i+1)%2][k]*ch[k][j]);
		}
	}
	double ans=0.0f;
	for(i=0;i<n;i++)ans=max(ans,dp[(m+1)%2][i]);
	printf("%.2lf\n",ans);
	}
}