#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cfloat>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
const double EPS = 1e-8;
inline int dcmp(double x) {
if (fabs(x) <= EPS) return 0;
else return x > 0 ? 1 : -1;
}
inline bool equal(double a, double b) {
return !dcmp(a - b);
}
const int MAX_N = 100;
const int MAX_NODE_NUM = 2 * MAX_N + 2;
const int MAX_EDGE_NUM = 2 * (MAX_N * MAX_N + 2 * MAX_N);
const double NEG_INF = -1e18;
namespace EK {
struct Node;
struct Edge;
struct Edge {
Node *fr, *to;
int cap, flow;
double cost;
int rev;
Edge(Node *fr, Node *to, int cap, double cost, int rev) : fr(fr), to(to), cap(cap), flow(0), cost(cost), rev(rev) {}
};
struct Node {
int flow;
double dist;
bool inq;
std::vector<Edge> edges;
Node *inNode;
int inEdge;
} N[MAX_NODE_NUM];
inline void addEdge(int fr, int to, int cap, double cost) {
N[fr].edges.push_back(Edge(&N[fr], &N[to], cap, cost, N[to].edges.size()));
N[to].edges.push_back(Edge(&N[to], &N[fr], 0, -cost, N[fr].edges.size() - 1));
}
int n;
Node *s, *t;
int maxFlow;
double minCost;
inline bool spfa() {
for (int i = 0; i < n; i++) N[i].dist = NEG_INF;
std::deque<Node *> q;
q.push_back(s), s->dist = 0, s->inq = true, s->flow = INT_MAX;
while (!q.empty()) {
Node *v = q.front();
q.pop_front();
v->inq = false;
for (int i = 0, n = v->edges.size(); i < n; i++) {
Edge *e = &v->edges[i];
if (e->cap > e->flow && e->to->dist < v->dist + e->cost) {
e->to->dist = v->dist + e->cost;
e->to->inNode = v;
e->to->inEdge = i;
e->to->flow = std::min(v->flow, e->cap - e->flow);
if (!e->to->inq) {
e->to->inq = true;
if (q.empty() || e->to->dist < q.front()->dist) q.push_front(e->to);
else q.push_back(e->to);
}
}
}
}
return !equal(t->dist, NEG_INF);
}
inline void argument() {
int flow = t->flow;
for (Edge *e = &t->inNode->edges[t->inEdge]; ;) {
e->flow += flow;
e->to->edges[e->rev].flow -= flow;
if (e->fr->inNode) e = &e->fr->inNode->edges[e->fr->inEdge];
else break;
}
maxFlow += flow;
minCost += t->dist * flow;
}
inline void solve(int s, int t, int n) {
EK::maxFlow = 0, EK::minCost = 0;
EK::s = &N[s], EK::t = &N[t], EK::n = n;
while (spfa()) argument();
}
inline void clear(int n) {
for (int i = 0; i < n; i++) N[i].edges.clear();
}
}
int n;
int a[MAX_N + 1][MAX_N + 1], b[MAX_N + 1][MAX_N + 1];
inline bool check(double bound) {
EK::clear(n * 2 + 2);
int s = 0, t = n * 2 + 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
EK::addEdge(i, j + n, 1, a[i][j] - bound * b[i][j]);
}
}
for (int i = 1; i <= n; i++) EK::addEdge(s, i, 1, 0);
for (int i = 1; i <= n; i++) EK::addEdge(i + n, t, 1, 0);
EK::solve(s, t, n * 2 + 2);
return dcmp(EK::minCost) >= 0;
}
inline double solve() {
double l = 0, r = 1e4;
while (r - l > EPS) {
double mid = (l + r) / 2;
if (check(mid)) l = mid; else r = mid;
}
return (l + r) / 2;
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) scanf("%d", &b[i][j]);
printf("%.6lf\n", solve());
return 0;
}