1 uses math;
2 const maxn=100+20;
3 var w,a:array[0..maxn] of longint;
4 x,i,j,k,n,m:longint;
5 f:array[0..maxn,0..1 shl 16] of double;
6 procedure init;
7 begin
8 readln(n,m);
9 for i:=1 to m do
10 begin
11 read(w[i]);a[i]:=0;
12 read(x);
13 while x<>0 do
14 begin
15 inc(a[i],1<<(x-1));
16 read(x);
17 end;
18 readln;
19 end;
20 end;
21 procedure main;
22 begin
23 for i:=n downto 1 do
24 for j:=0 to 1<<m-1 do
25 begin
26 f[i,j]:=0.0;
27 for k:=1 to m do
28 if j and a[k]<>a[k] then f[i,j]:=f[i,j]+f[i+1,j]
29 else
30 f[i,j]:=f[i,j]+max(f[i+1,j],f[i+1,j or (1<<(k-1))]+w[k]);
31 f[i,j]:=f[i,j]/m;
32 //writeln(i,‘ ‘,j,‘ ‘,f[i,j]);
33 end;
34 writeln(f[1,0]:0:6);
35 end;
36
37 begin
38 assign(input,‘input.txt‘);assign(output,‘output.txt‘);
39 reset(input);rewrite(output);
40 init;
41 main;
42 close(input);close(output);
43 end.