#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
using namespace std;
#define N 105
queue<int>que;
int p[N][N],t[N][N],vis[N],id[N];
double f[N][N],dis[N],mid;
int n;
int spfa(){
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
f[i][j]=(double)p[i][j]-(double)t[i][j]*mid;
memset(dis,-0x3f,sizeof(dis));
memset(vis,0,sizeof(vis));
memset(id,0,sizeof(id));
while(!que.empty()) que.pop();
que.push(1);
id[1]++;
vis[1]=1;
dis[1]=0.0;
while(!que.empty()){
int h=que.front();
que.pop();
vis[h]=0;
for(int i=1;i<=n;i++){
if(i==h) continue;
if(dis[i]<dis[h]+f[h][i]){
dis[i]=dis[h]+f[h][i];
if(!vis[i]){
vis[i]=1;
id[i]++;
if(id[i]>n) return 1;
que.push(i);
}
}
}
}
return dis[n]>=0?1:0;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
scanf("%d",&p[i][j]);
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
scanf("%d",&t[i][j]);
double l(0.0),r(10000.0),eps(0.0001);
while(r-l>eps){
mid=(l+r)/2.0;
if(spfa())
l=mid;
else
r=mid;
}
printf("%.3lf",mid);
return 0;
}