# BZOJ3993 星际战争(最大流)

#include<cstdio>
#include<cstring>
#include<vector>
#define MAXN 3010
#define INF 1e10
#define eps 1e-7
using namespace std;
inline double Min(double a,double b)
{return a<b?a:b;}
struct E
{
int v,op;
double w;
E(){}
E(int a,double b,int c)
{v = a; w = b; op = c;}
};
vector<E> g[MAXN];
int d[MAXN],vd[MAXN],n,m,s,t;
int a[MAXN],b[MAXN];
double sum,flow;
void add(int u,int v,double w)
{
g[u].push_back(E(v,w,g[v].size()));
g[v].push_back(E(u,0.0,g[u].size()-1));
}
double aug(int i,double augco)
{
int j,sz = g[i].size(),mind = t-1;
double delta,augc = augco;
if(i == t) return augco;

for(j = 0; j < sz; j++)
{
int v = g[i][j].v;
if(g[i][j].w > 0)
{
if(d[i] == d[v]+1)
{
delta = Min(augc,g[i][j].w);
delta = aug(v,delta);
g[i][j].w -= delta;
g[v][g[i][j].op].w += delta;
augc -= delta;
if(d[s] >= t) return augco-augc;
if(augc <= 0) break;
}
if(d[v] < mind) mind = d[v];
}
}
if(augc == augco)
{
vd[d[i]]--;
if(!vd[d[i]]) d[s] = t;
d[i] = mind+1;
vd[d[i]]++;
}
return augco-augc;
}
void sap()
{
flow = 0;
memset(d,0,sizeof d);
memset(vd,0,sizeof vd);
vd[0] = t;
while(d[s] < t)
flow += aug(s,(double)INF);
}
bool check(double k)
{
int i = 0,j,sz = g[s].size(),v;
for(i = 0; i < sz; i++)
{
v = g[s][i].v;
g[s][i].w = (double)b[v-n]*k;
g[v][g[s][i].op].w = 0.0;
}
for(i = 1; i <= n; i++)
{
sz = g[i].size();
for(j = 0; j < sz; j++)
{
v = g[i][j].v;
if(v == t) g[i][j].w = (double)a[i],g[t][g[i][j].op].w = 0.0;
else g[i][j].w = 0.0,g[v][g[i][j].op].w = (double)INF;
}
}
sap();
for(i = 1; i <= n; i++)
{
sz = g[i].size();
for(j = 0; j < sz; j++)
{
v = g[i][j].v;
if(v != t) continue;
if(g[i][j].w > eps) return false;
}
}
return true;
}
int main()
{
scanf("%d%d",&n,&m);
s = n+m+1,t = s+1;
for(int i = 1; i <= n; i++)
{
scanf("%d",&a[i]);
//sum += (double)a[i];
}
for(int i = 1; i <= m; i++)
{
scanf("%d",&b[i]);
}
int x;
for(int i = 1; i <= m; i++)
for(int j = 1; j <= n; j++)
{
scanf("%d",&x);
}