
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    m--;
    double v[100][100];
    rep(i,n)rep(j,n)cin>>v[i][j];
    double dp[105][105];
    rep(i,n) dp[0][i]=1;
    loop(i,1,m+1)rep(j,n){
      dp[i][j]=0;
      rep(k,n)
	dp[i][j]=max(dp[i][j],dp[i-1][k]*v[k][j]);
 
    }
    double ans=0;
    rep(i,n)ans=max(ans,dp[m][i]);
    cout<<shosu(2)<<ans<<endl;
  }
}