N,M=list(map(int,input().split()))
inf=10**10
dp=[[inf]*(2**N) for _ in range(M+1)]
dp[0][0]=0

for i in range(M):
    a,b=list(map(int,input().split()))
    c=list(map(int,input().split()))

    s=0
    for cc in c:
        s+=2**(cc-1)
    
    for j in range(2**N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|s]=min(dp[i+1][j|s],dp[i][j]+a)
    
print(dp[M][2**N-1] if dp[M][2**N-1]<inf else -1) N,M=list(map(int,input().split())) N list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split M inf=10**10 inf 10**10 10 10 [inf]*(2**N) for _ in range(M+1) for _ in range(M+1) _ range(M+1) range M+1 M 1 for _ in range(M+1) [inf]*(2**N) [inf] inf 2**N 2 N dp=[[inf]*(2**N) for _ in range(M+1)] dp [[inf]*(2**N) for _ in range(M+1)] dp[0][0]=0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    a,b=list(map(int,input().split()))
    c=list(map(int,input().split()))

    s=0
    for cc in c:
        s+=2**(cc-1)
    
    for j in range(2**N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|s]=min(dp[i+1][j|s],dp[i][j]+a)
     i range(M) range M a,b=list(map(int,input().split())) a list(map(int,input().split())) list 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 s=0 s 0 for cc in c:
        s+=2**(cc-1)
    
     cc c s+=2**(cc-1) s 2**(cc-1) 2 cc-1 cc 1 for j in range(2**N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|s]=min(dp[i+1][j|s],dp[i][j]+a)
     j range(2**N) range 2**N 2 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 dp[i+1][j|s]=min(dp[i+1][j|s],dp[i][j]+a) dp[i+1][j|s] [i+1] dp i+1 i 1 j|s j s min(dp[i+1][j|s],dp[i][j]+a) min dp[i+1][j|s] [i+1] dp i+1 i 1 j|s j s dp[i][j]+a dp[i][j] [i] dp i j a print(dp[M][2**N-1] if dp[M][2**N-1]<inf else -1) print dp[M][2**N-1] if dp[M][2**N-1]<inf else -1 dp[M][2**N-1]<inf dp[M][2**N-1] [M] dp M 2**N-1 2**N 2 N 1 inf dp[M][2**N-1] [M] dp M 2**N-1 2**N 2 N 1 -1 M=list(map(int,input().split())) list(map(int,input().split())) M b=list(map(int,input().split())) list(map(int,input().split())) b a,b=list(map(int,input().split())) list(map(int,input().split())) a dp=[[inf]*(2**N) for _ in range(M+1)] [[inf]*(2**N) for _ in range(M+1)] dp s+=2**(cc-1) 2**(cc-1) s inf=10**10 10**10 inf c=list(map(int,input().split())) list(map(int,input().split())) c N,M=list(map(int,input().split())) list(map(int,input().split())) N s=0 0 s
N,M=list(map(int,input().split()))
inf=10**10
dp=[[inf]*(2**N) for _ in range(M+1)]
dp[0][0]=0

for i in range(M):
    a,b=list(map(int,input().split()))
    c=list(map(int,input().split()))

    s=0
    for cc in c:
        s+=2**(cc-1)
    
    for j in range(2**N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][j|s]=min(dp[i+1][j|s],dp[i][j]+a)
    
print(dp[M][2**N-1] if dp[M][2**N-1]<inf else -1)
