N,M=map(int,input().split())
keys=[]
dp=[float("inf")]*pow(2,N)
dp[0]=0
for i in range(M):
    a,b=map(int,input().split())
    l=list(map(int,input().split()))
    num=0
    for j in l:
        num=num+pow(2,j-1)
    keys.append([a,num])
#print(keys)
for i in range(pow(2,N)):
    for j in range(M):
        dp[i|keys[j][1]]=min(dp[i|keys[j][1]],dp[i]+keys[j][0])
    #print(dp)
#print(dp)
if dp[pow(2,N)-1]==float("inf"):
    print(-1)
else:
    print(dp[pow(2,N)-1]) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M keys=[] keys [] dp=[float("inf")]*pow(2,N) dp [float("inf")]*pow(2,N) [float("inf")] float("inf") float "inf" pow(2,N) pow 2 N dp[0]=0 dp[0] dp 0 0 for i in range(M):
    a,b=map(int,input().split())
    l=list(map(int,input().split()))
    num=0
    for j in l:
        num=num+pow(2,j-1)
    keys.append([a,num])
#print(keys) i range(M) range M a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b l=list(map(int,input().split())) l list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split num=0 num 0 for j in l:
        num=num+pow(2,j-1)
     j l num=num+pow(2,j-1) num num+pow(2,j-1) num pow(2,j-1) pow 2 j-1 j 1 keys.append([a,num]) keys.append keys append [a,num] a num for i in range(pow(2,N)):
    for j in range(M):
        dp[i|keys[j][1]]=min(dp[i|keys[j][1]],dp[i]+keys[j][0])
    #print(dp)
#print(dp) i range(pow(2,N)) range pow(2,N) pow 2 N for j in range(M):
        dp[i|keys[j][1]]=min(dp[i|keys[j][1]],dp[i]+keys[j][0])
    #print(dp)
#print(dp) j range(M) range M dp[i|keys[j][1]]=min(dp[i|keys[j][1]],dp[i]+keys[j][0]) dp[i|keys[j][1]] dp i|keys[j][1] i keys[j][1] [j] keys j 1 min(dp[i|keys[j][1]],dp[i]+keys[j][0]) min dp[i|keys[j][1]] dp i|keys[j][1] i keys[j][1] [j] keys j 1 dp[i]+keys[j][0] dp[i] dp i keys[j][0] [j] keys j 0 if dp[pow(2,N)-1]==float("inf"):
    print(-1)
else:
    print(dp[pow(2,N)-1]) dp[pow(2,N)-1]==float("inf") dp[pow(2,N)-1] dp pow(2,N)-1 pow(2,N) pow 2 N 1 float("inf") float "inf" print(-1) print -1 print(dp[pow(2,N)-1]) print dp[pow(2,N)-1] dp pow(2,N)-1 pow(2,N) pow 2 N 1 dp=[float("inf")]*pow(2,N) [float("inf")]*pow(2,N) dp num=num+pow(2,j-1) num+pow(2,j-1) num l=list(map(int,input().split())) list(map(int,input().split())) l N,M=map(int,input().split()) map(int,input().split()) N M=map(int,input().split()) map(int,input().split()) M keys=[] [] keys num=0 0 num a,b=map(int,input().split()) map(int,input().split()) a b=map(int,input().split()) map(int,input().split()) b
N,M=map(int,input().split())
keys=[]
dp=[float("inf")]*pow(2,N)
dp[0]=0
for i in range(M):
    a,b=map(int,input().split())
    l=list(map(int,input().split()))
    num=0
    for j in l:
        num=num+pow(2,j-1)
    keys.append([a,num])
#print(keys)
for i in range(pow(2,N)):
    for j in range(M):
        dp[i|keys[j][1]]=min(dp[i|keys[j][1]],dp[i]+keys[j][0])
    #print(dp)
#print(dp)
if dp[pow(2,N)-1]==float("inf"):
    print(-1)
else:
    print(dp[pow(2,N)-1])