#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
const double eps=1e-6;
queue<int> q;
int n,m,cnt,S,T;
int A[60],B[60],C[60][60],to[100000],next[100000],head[110],d[110];
double ans,val[100000];
inline int rd()
{
int ret=0,f=1; char gc=getchar();
while(gc<‘0‘||gc>‘9‘) {if(gc==‘-‘)f=-f; gc=getchar();}
while(gc>=‘0‘&&gc<=‘9‘) ret=ret*10+gc-‘0‘,gc=getchar();
return ret*f;
}
void add(int a,int b,double c)
{
to[cnt]=b,val[cnt]=c,next[cnt]=head[a],head[a]=cnt++;
to[cnt]=a,val[cnt]=0,next[cnt]=head[b],head[b]=cnt++;
}
double dfs(int x,double mf)
{
if(x==T) return mf;
double k,temp=mf;
for(int i=head[x];i!=-1;i=next[i])
{
if(d[to[i]]==d[x]+1&&val[i]>eps)
{
k=dfs(to[i],min(temp,val[i]));
if(k<eps) d[to[i]]=0;
val[i]-=k,val[i^1]+=k,temp-=k;
if(temp<eps) break;
}
}
return mf-temp;
}
int bfs()
{
while(!q.empty()) q.pop();
memset(d,0,sizeof(d));
int u,i;
q.push(S),d[S]=1;
while(!q.empty())
{
u=q.front(),q.pop();
for(i=head[u];i!=-1;i=next[i])
{
if(!d[to[i]]&&val[i]>eps)
{
d[to[i]]=d[u]+1;
if(to[i]==T) return 1;
q.push(to[i]);
}
}
}
return 0;
}
bool check(double x)
{
int i,j;
memset(head,-1,sizeof(head)),cnt=0,ans=0,S=0,T=n+m+1;
for(i=1;i<=n;i++) add(S,i,A[i]),ans+=A[i];
for(i=1;i<=m;i++) add(i+n,T,B[i]*x);
for(i=1;i<=m;i++) for(j=1;j<=n;j++) if(C[i][j]) add(j,i+n,999999);
while(bfs()) ans-=dfs(S,99999999);
return ans<eps;
}
int main()
{
n=rd(),m=rd();
int i,j;
for(i=1;i<=n;i++) A[i]=rd();
for(i=1;i<=m;i++) B[i]=rd();
for(i=1;i<=m;i++) for(j=1;j<=n;j++) C[i][j]=rd();
double l=0,r=500000,mid;
while(r-l>eps)
{
mid=(l+r)*0.5;
if(check(mid)) r=mid;
else l=mid;
}
printf("%.6lf",r);
return 0;
}