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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

int main(){
  int n,m;
  double table[100][100];
  while(cin>>n>>m,n){
    REP(i,n)REP(j,n)cin>>table[i][j]; //j->i
    vector<double> dp(n,1.0);
    REP(i,m-1){
      vector<double> ndp(n);
      REP(j,n)REP(k,n)ndp[k] = max(ndp[k],table[k][j] * dp[j]); //j->k
      dp = ndp;
    }
    double ans = 0;
    REP(i,n)ans = max(ans,dp[i]);
    /*
    int intans = ans * 1000;
    if(intans % 10 < 5) {
      intans -= intans % 10;
    }else{
      intans += (10 - intans % 10);
    }
    ans = (double)intans / 1000;
    */
    printf("%0.2lf\n",ans);
  }
  return 0;
}