#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<vector<double> > x(n, vector<double>(n));
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                cin >> x[i][j];
            }
        }

        vector<double> y(n, 1.0);
        while(--m > 0){
            vector<double> z(n, 0.0);
            for(int i=0; i<n; ++i){
                for(int j=0; j<n; ++j){
                    z[i] = max(z[i], y[j] * x[j][i]);
                }
            }
            y = z;
        }

        double ret = *max_element(y.begin(), y.end());
        printf("%.2f\n", ret);
    }
}