/*
由题意可得 (P1+...+Pn)/(T1+...Tn)=ans
-------> ans*(T1+...Tn)=(P1+...+Pn)
-------> P1-ans*T1+...+Pn-ans*Tn=0
所以我们可以二分一个ans,根据f=p-ans*t 计算出一个f[][],
然后用SPFA求最长路检验ans,如果一个形成正环,则说明一定存在更优的解,
且当dis[n]>0时,也存在更优的解,否则,该ans不正确
*/
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
int n;
queue<int>q;
#define maxn 110
double s[maxn][maxn],t[maxn][maxn],dis[maxn],l,r,a[maxn][maxn],step[maxn];
bool vis[maxn];
bool spfa(){
memset(dis,-0x3f3f3f3f,sizeof(dis));
memset(step,0,sizeof(step));
memset(vis,0,sizeof(vis));
while(!q.empty())q.pop();
q.push(1);vis[1]=1;dis[1]=0;
while(!q.empty()){
int point=q.front();q.pop();vis[point]=0;
for(int i=1;i<=n;i++){
if(i!=point&&dis[i]<dis[point]+a[point][i]){
dis[i]=dis[point]+a[point][i];
if(!vis[i]){
vis[i]=1;
q.push(i);
step[i]++;
if(step[i]>n)return 1;
}
}
}
}
if(dis[n]>0)return 1;
return 0;
}
bool check(double x){
memset(a,0,sizeof(a));
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
a[i][j]=s[i][j]-x*t[i][j];
if(spfa())return 1;
else return 0;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)scanf("%lf",&s[i][j]);
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)scanf("%lf",&t[i][j]);
l=0;r=100000;
while(r-l>0.0001){
double mid=(l+r)/2.0;
if(check(mid))l=mid;
else r=mid;
}
printf("%.3lf",l);
}