#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,m;
const int MAX_N =120;
const int MAX_M =120;
double dp[MAX_N][MAX_M];//dp[i][j]:=直前にjを与え、i回目に肥料を与えたときの最大の成長
double memo[MAX_N][MAX_N];
int main(){
	while(1){
		cin>>n>>m;
		if(n==0&&m==0){
			break;
		}
		for(int i =0;i <MAX_N;i++){
			for(int j =0;j <MAX_N;j++){
				dp[i][j] =0;
				memo[i][j]=0;
			}
		}
		rep(i,n){
			rep(j,n){
				cin>>memo[i][j];
			}
		}
		bool flag =false;
		if(m==1){
			printf("%.2f\n",1.00);
			continue;
		}

		rep(i,n)dp[1][i] =1;

		double ans =0;
		for(int i =1;i <m;i++){
			for(int k =0;k <n;k++){//直前
				for(int j =0;j <n;j++){//直後
					dp[i+1][j] =max(dp[i+1][j],dp[i][k]*memo[k][j]);
					if(dp[i+1][j]>ans){
						ans =dp[i+1][j];
					}
				}
			}
		}
		ans +=0.005;
		ans =ans*100;
		ans =(int)ans;
		ans =(double)ans/100;
		printf("%.2f\n",m==1?1:ans);
	}
	return 0;
}