# coding: utf-8
# Your code here!
#D流用したので文字滅茶苦茶
N,M=map(int,input().split())

dp=[10**10]*2**N
dp[0]=0

for _ in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    
    can_open=sum([2**(c[i]-1) for i in range(len(c))])
    
    for i in range(len(dp))[::-1]:
        if dp[i]!=10**10 and i|can_open<2**N:
            dp[i|can_open]=min(dp[i]+a,dp[i|can_open])


if dp[-1]==10**10:
    print(-1)
else:
    print(dp[-1]) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M dp=[10**10]*2**N dp [10**10]*2**N [10**10] 10**10 10 10 2**N 2 N dp[0]=0 dp[0] dp 0 0 for _ in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    
    can_open=sum([2**(c[i]-1) for i in range(len(c))])
    
    for i in range(len(dp))[::-1]:
        if dp[i]!=10**10 and i|can_open<2**N:
            dp[i|can_open]=min(dp[i]+a,dp[i|can_open]) _ 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 2**(c[i]-1) for i in range(len(c)) for i in range(len(c)) i range(len(c)) range len(c) len c for i in range(len(c)) 2**(c[i]-1) 2 c[i]-1 c[i] c i 1 can_open=sum([2**(c[i]-1) for i in range(len(c))]) can_open sum([2**(c[i]-1) for i in range(len(c))]) sum [2**(c[i]-1) for i in range(len(c))] for i in range(len(dp))[::-1]:
        if dp[i]!=10**10 and i|can_open<2**N:
            dp[i|can_open]=min(dp[i]+a,dp[i|can_open]) i range(len(dp))[::-1] (len(dp)) range len(dp) len dp ::-1 -1 if dp[i]!=10**10 and i|can_open<2**N:
            dp[i|can_open]=min(dp[i]+a,dp[i|can_open]) dp[i]!=10**10 and i|can_open<2**N dp[i]!=10**10 dp[i] dp i 10**10 10 10 i|can_open<2**N i|can_open i can_open 2**N 2 N dp[i|can_open]=min(dp[i]+a,dp[i|can_open]) dp[i|can_open] dp i|can_open i can_open min(dp[i]+a,dp[i|can_open]) min dp[i]+a dp[i] dp i a dp[i|can_open] dp i|can_open i can_open if dp[-1]==10**10:
    print(-1)
else:
    print(dp[-1]) dp[-1]==10**10 dp[-1] dp -1 10**10 10 10 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 c=list(map(int,input().split())) list(map(int,input().split())) c b=map(int,input().split()) map(int,input().split()) b dp=[10**10]*2**N [10**10]*2**N dp can_open=sum([2**(c[i]-1) for i in range(len(c))]) sum([2**(c[i]-1) for i in range(len(c))]) can_open M=map(int,input().split()) map(int,input().split()) M a,b=map(int,input().split()) map(int,input().split()) a N,M=map(int,input().split()) map(int,input().split()) N
# coding: utf-8
# Your code here!
#D流用したので文字滅茶苦茶
N,M=map(int,input().split())

dp=[10**10]*2**N
dp[0]=0

for _ in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    
    can_open=sum([2**(c[i]-1) for i in range(len(c))])
    
    for i in range(len(dp))[::-1]:
        if dp[i]!=10**10 and i|can_open<2**N:
            dp[i|can_open]=min(dp[i]+a,dp[i|can_open])


if dp[-1]==10**10:
    print(-1)
else:
    print(dp[-1])
