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

dp=[10**9]*(1<<n)
dp[0]=0
for _ in range(m):
    a,b=map(int,input().split())
    key=0
    for i in map(int,input().split()):
        key+=1<<(i-1)
    for i in range(1<<n):
        dp[i|key]=min(dp[i|key],dp[i]+a)
if dp[-1]>10**8:
    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**9]*(1<<n) dp [10**9]*(1<<n) [10**9] 10**9 10 9 1<<n 1 n dp[0]=0 dp[0] dp 0 0 for _ in range(m):
    a,b=map(int,input().split())
    key=0
    for i in map(int,input().split()):
        key+=1<<(i-1)
    for i in range(1<<n):
        dp[i|key]=min(dp[i|key],dp[i]+a) _ range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b key=0 key 0 for i in map(int,input().split()):
        key+=1<<(i-1)
     i map(int,input().split()) map int input().split() ().split () input split key+=1<<(i-1) key 1<<(i-1) 1 i-1 i 1 for i in range(1<<n):
        dp[i|key]=min(dp[i|key],dp[i]+a) i range(1<<n) range 1<<n 1 n dp[i|key]=min(dp[i|key],dp[i]+a) dp[i|key] dp i|key i key min(dp[i|key],dp[i]+a) min dp[i|key] dp i|key i key dp[i]+a dp[i] dp i a if dp[-1]>10**8:
    print(-1)
else:
    print(dp[-1]) dp[-1]>10**8 dp[-1] dp -1 10**8 10 8 print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 n,m=map(int,input().split()) map(int,input().split()) n m=map(int,input().split()) map(int,input().split()) m a,b=map(int,input().split()) map(int,input().split()) a key+=1<<(i-1) 1<<(i-1) key dp=[10**9]*(1<<n) [10**9]*(1<<n) dp b=map(int,input().split()) map(int,input().split()) b key=0 0 key
n,m=map(int,input().split())

dp=[10**9]*(1<<n)
dp[0]=0
for _ in range(m):
    a,b=map(int,input().split())
    key=0
    for i in map(int,input().split()):
        key+=1<<(i-1)
    for i in range(1<<n):
        dp[i|key]=min(dp[i|key],dp[i]+a)
if dp[-1]>10**8:
    print(-1)
else:
    print(dp[-1])