INF=10**18
N,M=map(int,input().split())

a,c=[],[]
for i in range(M):
    A,B=map(int,input().split())  
    C=list(map(int,input().split()))
    tmp=0
    for j in range(B):
      tmp+=1<<(C[j]-1)
    a.append(A)
    c.append(tmp)
    
dp=[[INF]*(1<<N) for i in range(M+1)]
dp[0][0]=0
for i in range(M):
    for j in range(1<<N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        o=(j | c[i])
        dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i])
ans=dp[M][2**N-1]
print(ans if ans!=INF else -1) INF=10**18 INF 10**18 10 18 N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M a,c=[],[] a [] c [] for i in range(M):
    A,B=map(int,input().split())  
    C=list(map(int,input().split()))
    tmp=0
    for j in range(B):
      tmp+=1<<(C[j]-1)
    a.append(A)
    c.append(tmp)
     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 tmp=0 tmp 0 for j in range(B):
      tmp+=1<<(C[j]-1)
     j range(B) range B tmp+=1<<(C[j]-1) tmp 1<<(C[j]-1) 1 C[j]-1 C[j] C j 1 a.append(A) a.append a append A c.append(tmp) c.append c append tmp [INF]*(1<<N) for i in range(M+1) for i in range(M+1) i range(M+1) range M+1 M 1 for i in range(M+1) [INF]*(1<<N) [INF] INF 1<<N 1 N dp=[[INF]*(1<<N) for i in range(M+1)] dp [[INF]*(1<<N) for i in range(M+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    for j in range(1<<N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        o=(j | c[i])
        dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i]) i range(M) range M for j in range(1<<N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        o=(j | c[i])
        dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i]) j range(1<<N) range 1<<N 1 N dp[i+1][j]=min(dp[i+1][j],dp[i][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i+1][j],dp[i][j]) min dp[i+1][j] [i+1] dp i+1 i 1 j dp[i][j] [i] dp i j o=(j | c[i]) o j | c[i] j c[i] c i dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i]) dp[i+1][o] [i+1] dp i+1 i 1 o min(dp[i+1][o],dp[i][j]+a[i]) min dp[i+1][o] [i+1] dp i+1 i 1 o dp[i][j]+a[i] dp[i][j] [i] dp i j a[i] a i ans=dp[M][2**N-1] ans dp[M][2**N-1] [M] dp M 2**N-1 2**N 2 N 1 print(ans if ans!=INF else -1) print ans if ans!=INF else -1 ans!=INF ans INF ans -1 c=[],[] [] c B=map(int,input().split()) map(int,input().split()) B C=list(map(int,input().split())) list(map(int,input().split())) C A,B=map(int,input().split()) map(int,input().split()) A tmp+=1<<(C[j]-1) 1<<(C[j]-1) tmp INF=10**18 10**18 INF a,c=[],[] [] a M=map(int,input().split()) map(int,input().split()) M ans=dp[M][2**N-1] dp[M][2**N-1] ans o=(j | c[i]) j | c[i] o N,M=map(int,input().split()) map(int,input().split()) N tmp=0 0 tmp dp=[[INF]*(1<<N) for i in range(M+1)] [[INF]*(1<<N) for i in range(M+1)] dp
INF=10**18
N,M=map(int,input().split())

a,c=[],[]
for i in range(M):
    A,B=map(int,input().split())  
    C=list(map(int,input().split()))
    tmp=0
    for j in range(B):
      tmp+=1<<(C[j]-1)
    a.append(A)
    c.append(tmp)
    
dp=[[INF]*(1<<N) for i in range(M+1)]
dp[0][0]=0
for i in range(M):
    for j in range(1<<N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        o=(j | c[i])
        dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i])
ans=dp[M][2**N-1]
print(ans if ans!=INF else -1)