#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
int n, m;
double cal(double g[][101]) {
  int i, j, k;
  double dp[110][110] = {};
  // double MAX = 0.0;
  double all_MAX = 0.0;
  
  for(i = 1; i <= n; i++) {
    dp[1][i] = 1.0;
  }
  
  for(i = 2; i <= m; i++)
    for(j = 1; j <= n; j++) {
      dp[i][j] = 0.0;
      for(k = 1; k <= n; k++) {
	dp[i][j] = max(dp[i-1][k]*g[k][j], dp[i][j]);
      }
    }
  
  for(i = 1; i <= m; i++) {
    for(j = 1; j <= n; j++){
      // cout << dp[i][j] << ' ';
      all_MAX = max(dp[i][j], all_MAX);
    }
    // cout << endl;
  }
  
  return all_MAX;
}

	  
int main() {
  int i, j;
  while(cin >> n >> m, n != 0 || m != 0) {
    double g[101][101] = {};
    
    for(i = 1; i <= n; i++)
      for(j = 1; j <= n; j++)
	cin >> g[i][j];
    printf("%.2f\n", cal(g));
  }
  
  return 0;
}