#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

double solve(int n, int m){
  vector<vector<double>> tbl(n,vector<double>(n));
  rep(i,n) rep(j,n) cin>>tbl[i][j];

  vector<vector<double>> dp(m, vector<double>(n, -INF));
  rep(i,n) dp[0][i] = 1.0;
  repl(i,1,m) rep(j,n) rep(k,n) dp[i][j] = max(dp[i][j], dp[i-1][k] * tbl[k][j]);
  return *max_element(all(dp[m-1]));
}

int main(){
  int n,m;
  while(cin>>n>>m, n|m){
    printf("%.2f\n", solve(n,m));
  }

  return 0;
}