#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define eps 1e-4
#define INF 100000007
using namespace std;
int n,m,sumA,sumB,a[51],b[51],PointSum,x,q[200],ll[51][51];
double l,r,map[200][200],dis[200];
bool BFS()
{
for (int i=1;i<=PointSum;i++) dis[i]=-1;
int t=0,w=1,x;
dis[1]=0;
q[1]=1;
while (t<w)
{
x=q[++t];
for (int i=1;i<=PointSum;i++)
if (map[x][i]>0&&dis[i]<0)
{
dis[i]=dis[x]+1;
q[++w]=i;
}
}
if (dis[PointSum]>0) return 1; else return 0;
}
double find(int x,double flow)
{
if (x==PointSum) return flow;
double used=0,w;
for (int i=1;i<=PointSum;i++)
if (map[x][i]>0&&dis[i]==dis[x]+1)
{
w=flow-used;
w=find(i,min(map[x][i],w));
map[x][i]-=w;
map[i][x]+=w;
used+=w;
if (used==flow) return flow;
}
if (used<eps) dis[x]=-1;
return used;
}
void MadePaint(double t)
{
for (int i=1;i<=m;i++)
for (int j=1;j<=n;j++)
{
map[i+1][j+m+1]=0;
map[j+m+1][i+1]=0;
}
for (int i=1;i<=m;i++) map[1][i+1]=t*b[i];
for (int i=1;i<=m;i++)
for (int j=1;j<=n;j++)
if (ll[i][j]) map[i+1][j+m+1]=INF;
for (int i=1;i<=n;i++) map[i+m+1][PointSum]=a[i];
}
bool dinic(double t)
{
MadePaint(t);
double ans=0;
while (BFS()) ans+=find(1,100000007);
return fabs(ans-double(sumA))<eps;
}
int main()
{
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
sumA+=a[i];
}
for (int i=1;i<=m;i++)
{
scanf("%d",&b[i]);
sumB+=b[i];
}
l=double(sumA)/double(sumB);
r=double(sumA);
PointSum=n+m+2;
for (int i=1;i<=m;i++)
for (int j=1;j<=n;j++)
scanf("%d",&ll[i][j]);
while (l+eps<r)
{
double mid=(l+r)/2;
if (dinic(mid)) r=mid;
else l=mid;
}
printf("%.6lf",r);
return 0;
}