#include<iostream>
#include<cstdio>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e6
using namespace std;

int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		double dt[n][n],dp[m][n];
		rep(i,n)rep(j,n)cin>>dt[i][j];
		rep(i,m)rep(j,n)dp[i][j]=-1*INF;
		rep(i,n)dp[0][i]=1.0;
		rep(i,m-1){
			rep(j,n){
				rep(k,n){
					dp[i+1][k]=max(dp[i+1][k],dp[i][j]*dt[j][k]);
				}
			}
		}
		double ans=-1;
		rep(i,n)ans=max(ans,dp[m-1][i]);
		printf("%.2f\n",ans);
	}
	return 0;
}