#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

double dp[105][105];
double g[105][105];

double solve(int n, int m){
    rep(i,n) dp[0][i] = 1;
    range(i,1,m){
        rep(j,n){
            rep(k,n){
                dp[i][j] = max(dp[i][j], dp[i - 1][k] * g[k][j]);
            }
        }
    }

    double retval = 0;
    rep(i,n){
        retval = max(dp[m - 1][i], retval);
    }
    return retval;
}

int main(){
    int n, m;
    while(cin >> n >> m, n||m){
        rep(i,105) rep(j,105) dp[i][j] = 0;
        rep(i,n) rep(j,n) cin >> g[i][j];
        cout << solve(n, m) << endl;
    }
}