#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a||b){
    vector<vector<double> >in(a,vector<double>(a));
    rep(i,a)rep(j,a)cin>>in[i][j];
    vector<vector<double> >out(b,vector<double>(a));
    rep(i,a)out[0][i]=1.0;
    rep(i,b-1){
      rep(j,a){
	double max1=0;
	rep(k,a)if(max1<out[i][k]*in[k][j])max1=out[i][k]*in[k][j];
	out[i+1][j]=max1;
      }
    }
    double max1=0;
    rep(i,a)if(max1<out[b-1][i])max1=out[b-1][i];
    //double tmp=max1*100-(int)(max1*100);
    //printf("%.3f\n",tmp);
    //if(tmp-0.50>=-ESP)max1+=0.01;
    printf("%.2f\n",max1);
  }
}