N,M=map(int,input().split())
lst=[0]*M
for i in range(M):
 a,b=map(int,input().split())
 c=list(map(int,input().split()))
 d=0
 for n in range(b):
  d+=2**(c[n]-1)
  lst[i]=(a,d)
ans=[[float("inf") for e in range(2**N)] for f in range(M+1)]
ans[0][0]=0
for j in range(M):
 for i in range(2**N):
  e= i-(lst[j][1]&i)
  ans[j+1][i]=min(ans[j][e]+lst[j][0],ans[j][i])
if ans[M][2**N-1]==float("inf"):
 print(-1)
else:
 print(ans[M][2**N-1]) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M lst=[0]*M lst [0]*M [0] 0 M for i in range(M):
 a,b=map(int,input().split())
 c=list(map(int,input().split()))
 d=0
 for n in range(b):
  d+=2**(c[n]-1)
  lst[i]=(a,d) i range(M) range M a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b c=list(map(int,input().split())) c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split d=0 d 0 for n in range(b):
  d+=2**(c[n]-1)
  lst[i]=(a,d) n range(b) range b d+=2**(c[n]-1) d 2**(c[n]-1) 2 c[n]-1 c[n] c n 1 lst[i]=(a,d) lst[i] lst i (a,d) a d [float("inf") for e in range(2**N)] for f in range(M+1) for f in range(M+1) f range(M+1) range M+1 M 1 for f in range(M+1) [float("inf") for e in range(2**N)] ans=[[float("inf") for e in range(2**N)] for f in range(M+1)] ans [[float("inf") for e in range(2**N)] for f in range(M+1)] ans[0][0]=0 ans[0][0] [0] ans 0 0 0 for j in range(M):
 for i in range(2**N):
  e= i-(lst[j][1]&i)
  ans[j+1][i]=min(ans[j][e]+lst[j][0],ans[j][i]) j range(M) range M for i in range(2**N):
  e= i-(lst[j][1]&i)
  ans[j+1][i]=min(ans[j][e]+lst[j][0],ans[j][i]) i range(2**N) range 2**N 2 N e= i-(lst[j][1]&i) e i-(lst[j][1]&i) i lst[j][1]&i lst[j][1] [j] lst j 1 i ans[j+1][i]=min(ans[j][e]+lst[j][0],ans[j][i]) ans[j+1][i] [j+1] ans j+1 j 1 i min(ans[j][e]+lst[j][0],ans[j][i]) min ans[j][e]+lst[j][0] ans[j][e] [j] ans j e lst[j][0] [j] lst j 0 ans[j][i] [j] ans j i if ans[M][2**N-1]==float("inf"):
 print(-1)
else:
 print(ans[M][2**N-1]) ans[M][2**N-1]==float("inf") ans[M][2**N-1] [M] ans M 2**N-1 2**N 2 N 1 float("inf") float "inf" print(-1) print -1 print(ans[M][2**N-1]) print ans[M][2**N-1] [M] ans M 2**N-1 2**N 2 N 1 M=map(int,input().split()) map(int,input().split()) M N,M=map(int,input().split()) map(int,input().split()) N d+=2**(c[n]-1) 2**(c[n]-1) d lst=[0]*M [0]*M lst d=0 0 d ans=[[float("inf") for e in range(2**N)] for f in range(M+1)] [[float("inf") for e in range(2**N)] for f in range(M+1)] ans e= i-(lst[j][1]&i) i-(lst[j][1]&i) e b=map(int,input().split()) map(int,input().split()) b a,b=map(int,input().split()) map(int,input().split()) a c=list(map(int,input().split())) list(map(int,input().split())) c
N,M=map(int,input().split())
lst=[0]*M
for i in range(M):
 a,b=map(int,input().split())
 c=list(map(int,input().split()))
 d=0
 for n in range(b):
  d+=2**(c[n]-1)
  lst[i]=(a,d)
ans=[[float("inf") for e in range(2**N)] for f in range(M+1)]
ans[0][0]=0
for j in range(M):
 for i in range(2**N):
  e= i-(lst[j][1]&i)
  ans[j+1][i]=min(ans[j][e]+lst[j][0],ans[j][i])
if ans[M][2**N-1]==float("inf"):
 print(-1)
else:
 print(ans[M][2**N-1])