

N,M=map(int, input().split())
key=[]
for i in range(M):
    a,b=map(int, input().split())
    C=list(map(int, input().split()))
    c=0
    for d in C:
        c+=2**(d-1)
    key.append((a,b,c))

dp=[10**8+10]*(2**N)
dp[0]=0
for bi in range(0,2**N):
    for i in range(M):
        t=key[i]
        a,b,c=t
        

        dp[bi|c]=min(dp[bi]+a,dp[bi|c])
if dp[-1]<10**8+10:
    print(int(dp[-1]))
else:
    print(-1)
    
 N,M=map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M key=[] key [] for i in range(M):
    a,b=map(int, input().split())
    C=list(map(int, input().split()))
    c=0
    for d in C:
        c+=2**(d-1)
    key.append((a,b,c)) 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 c=0 c 0 for d in C:
        c+=2**(d-1)
     d C c+=2**(d-1) c 2**(d-1) 2 d-1 d 1 key.append((a,b,c)) key.append key append (a,b,c) a b c dp=[10**8+10]*(2**N) dp [10**8+10]*(2**N) [10**8+10] 10**8+10 10**8 10 8 10 2**N 2 N dp[0]=0 dp[0] dp 0 0 for bi in range(0,2**N):
    for i in range(M):
        t=key[i]
        a,b,c=t
        

        dp[bi|c]=min(dp[bi]+a,dp[bi|c]) bi range(0,2**N) range 0 2**N 2 N for i in range(M):
        t=key[i]
        a,b,c=t
        

        dp[bi|c]=min(dp[bi]+a,dp[bi|c]) i range(M) range M t=key[i] t key[i] key i a,b,c=t a t b c dp[bi|c]=min(dp[bi]+a,dp[bi|c]) dp[bi|c] dp bi|c bi c min(dp[bi]+a,dp[bi|c]) min dp[bi]+a dp[bi] dp bi a dp[bi|c] dp bi|c bi c if dp[-1]<10**8+10:
    print(int(dp[-1]))
else:
    print(-1)
     dp[-1]<10**8+10 dp[-1] dp -1 10**8+10 10**8 10 8 10 print(int(dp[-1])) print int(dp[-1]) int dp[-1] dp -1 print(-1) print -1 C=list(map(int, input().split())) list(map(int, input().split())) C c=0 0 c a,b=map(int, input().split()) map(int, input().split()) a c=t t c c+=2**(d-1) 2**(d-1) c key=[] [] key M=map(int, input().split()) map(int, input().split()) M N,M=map(int, input().split()) map(int, input().split()) N b=map(int, input().split()) map(int, input().split()) b dp=[10**8+10]*(2**N) [10**8+10]*(2**N) dp b,c=t t b t=key[i] key[i] t a,b,c=t t a


N,M=map(int, input().split())
key=[]
for i in range(M):
    a,b=map(int, input().split())
    C=list(map(int, input().split()))
    c=0
    for d in C:
        c+=2**(d-1)
    key.append((a,b,c))

dp=[10**8+10]*(2**N)
dp[0]=0
for bi in range(0,2**N):
    for i in range(M):
        t=key[i]
        a,b,c=t
        

        dp[bi|c]=min(dp[bi]+a,dp[bi|c])
if dp[-1]<10**8+10:
    print(int(dp[-1]))
else:
    print(-1)
    

