#include <iostream>
#include <cmath>
using namespace std;

const int MAX_N = 100, MAX_M = 100;
const double EPS = 1e-10;

int n,m;
double g[MAX_N][MAX_N];
double dp[MAX_M][MAX_N]; //dp[cnt][prev]

double rec(int cnt, int prev)
{

    if(cnt == 0)
        return dp[0][prev] = 1.0;

    if(dp[cnt][prev] > 0.0)
        return dp[cnt][prev];
    
    double tmp, ret = 0.0;
    for(int i = 0; i < n; i++) {
        tmp = rec(cnt - 1, i) * g[prev][i];
        if(ret < tmp) 
            ret = tmp;
    }

    return dp[cnt][prev] = ret;
}

int main()
{
    while(cin >> n >> m && n) {
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++) 
                cin >> g[i][j];

        for(int i = 0; i < m; i++) 
            for(int j = 0; j < n; j++) 
                scanf("%lf", &g[i][j]);

        double ans = 0.0, tmp;
        for(int i = 0; i < n; i++) {
            tmp = rec(m - 1, i);
            if(ans < tmp)
                ans = tmp;
        }

        printf("%.2lf", ans);
    }
}