n,m=map(int,input().split())

dp=[float('inf')]*(2**n)
dp[0]=0

for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    cnt=0
    for j in c:
        cnt+=2**(j-1)
    
    for j in range(2**n):
        dp[j|cnt]=min(dp[j|cnt],dp[j]+a)


if dp[2**n-1]>10**10:
    print(-1)

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

else:
    print(dp[2**n-1]) dp[2**n-1]>10**10 dp[2**n-1] dp 2**n-1 2**n 2 n 1 10**10 10 10 print(-1) print -1 print(dp[2**n-1]) print dp[2**n-1] dp 2**n-1 2**n 2 n 1 n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m cnt+=2**(j-1) 2**(j-1) cnt a,b=map(int,input().split()) map(int,input().split()) a c=list(map(int,input().split())) list(map(int,input().split())) c dp=[float('inf')]*(2**n) [float('inf')]*(2**n) dp b=map(int,input().split()) map(int,input().split()) b cnt=0 0 cnt
n,m=map(int,input().split())

dp=[float('inf')]*(2**n)
dp[0]=0

for i in range(m):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    cnt=0
    for j in c:
        cnt+=2**(j-1)
    
    for j in range(2**n):
        dp[j|cnt]=min(dp[j|cnt],dp[j]+a)


if dp[2**n-1]>10**10:
    print(-1)

else:
    print(dp[2**n-1])