#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

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

const int MAX_N = 101;
const int MAX_M = 101;
int N, M;
double table[MAX_N][MAX_N];
double dp[MAX_M][MAX_N]; 

void solve() {
	rep(i,M) rep(j,N) dp[i][j] = 0.0;

	rep(i,N) dp[0][i] = 1.0;
	repa(i,1,M-1) {
		rep(j,N) {
			double maxval = dp[i-1][j];
			rep(k,N) {
				double s = dp[i-1][k] * table[k][j];
				maxval = max(s, maxval);
			}
			dp[i][j] = maxval;
		}
	}

	double maxval = 0.0;
	rep(i,N) {
		maxval = max(maxval, dp[M-1][i]);
	}
	printf("%.6f\n", maxval);
}

int main() {
	while(scanf("%d%d",&N,&M), N|M) {
		rep(i,N) {
			rep(j,N) {
				scanf("%lf", &table[i][j]);
			}
		}
		solve();
	}
}