Code
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 110
#define db double
using namespace std;
int n,m,nd[N],v[N];
db f[N][1<<16];
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
db DP(int i,int S){
if(i>m) return 0;
db &tmp=f[i][S];
if(tmp+1e9>1e-9) return tmp;
tmp=0;
for(int j=1;j<=n;++j)
if((S|nd[j])==S)
tmp+=max(DP(i+1,S),DP(i+1,S|(1<<(j-1)))+v[j]);
else tmp+=DP(i+1,S);
tmp/=n;
return tmp;
}
int main(){
m=read(),n=read();
for(int i=1;i<=n;++i){
v[i]=read();
for(int x=read();x!=0;x=read()) nd[i]|=(1<<(x-1));
}
for(int i=0;i<=m;++i)for(int j=0;j<(1<<n);++j)f[i][j]=-2e9;
printf("%.6lf
",DP(1,0));
}