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

node=2**N

dp=[[10**10 for i in range(0,node)] for j in range(0,M)]

for i in range(0,M):
    dp[i][node-1]=0
#i:何番までか j:手に入れた鍵
for i in range(0,M):
    for j in range(1,node):
        k=node-1-j
        if i==0:
            if k|key[0]==node-1:
                dp[0][k]=cost[0]
        else:
            dp[i][k]=min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i])

if dp[M-1][0]>=10**10:
    print(-1)
else:
    print(dp[M-1][0]) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M key=[] key [] cost=[] cost [] for i in range(0,M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    s=sum(2**(c[j]-1) for j in range(0,b))
    key.append(s)
    cost.append(a) i range(0,M) range 0 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 s=sum(2**(c[j]-1) for j in range(0,b)) s sum(2**(c[j]-1) for j in range(0,b)) sum 2**(c[j]-1) 2 c[j]-1 c[j] c j 1 key.append(s) key.append key append s cost.append(a) cost.append cost append a node=2**N node 2**N 2 N [10**10 for i in range(0,node)] for j in range(0,M) for j in range(0,M) j range(0,M) range 0 M for j in range(0,M) [10**10 for i in range(0,node)] dp=[[10**10 for i in range(0,node)] for j in range(0,M)] dp [[10**10 for i in range(0,node)] for j in range(0,M)] for i in range(0,M):
    dp[i][node-1]=0
#i:何番までか j:手に入れた鍵 i range(0,M) range 0 M dp[i][node-1]=0 dp[i][node-1] [i] dp i node-1 node 1 0 for i in range(0,M):
    for j in range(1,node):
        k=node-1-j
        if i==0:
            if k|key[0]==node-1:
                dp[0][k]=cost[0]
        else:
            dp[i][k]=min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i]) i range(0,M) range 0 M for j in range(1,node):
        k=node-1-j
        if i==0:
            if k|key[0]==node-1:
                dp[0][k]=cost[0]
        else:
            dp[i][k]=min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i]) j range(1,node) range 1 node k=node-1-j k node-1-j node-1 node 1 j if i==0:
            if k|key[0]==node-1:
                dp[0][k]=cost[0]
        else:
            dp[i][k]=min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i]) i==0 i 0 if k|key[0]==node-1:
                dp[0][k]=cost[0]
         k|key[0]==node-1 k|key[0] k key[0] key 0 node-1 node 1 dp[0][k]=cost[0] dp[0][k] [0] dp 0 k cost[0] cost 0 dp[i][k]=min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i]) dp[i][k] [i] dp i k min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i]) min dp[i-1][k] [i-1] dp i-1 i 1 k dp[i-1][k|key[i]]+cost[i] dp[i-1][k|key[i]] [i-1] dp i-1 i 1 k|key[i] k key[i] key i cost[i] cost i if dp[M-1][0]>=10**10:
    print(-1)
else:
    print(dp[M-1][0]) dp[M-1][0]>=10**10 dp[M-1][0] [M-1] dp M-1 M 1 0 10**10 10 10 print(-1) print -1 print(dp[M-1][0]) print dp[M-1][0] [M-1] dp M-1 M 1 0 s=sum(2**(c[j]-1) for j in range(0,b)) sum(2**(c[j]-1) for j in range(0,b)) s c=list(map(int,input().split())) list(map(int,input().split())) c N,M=map(int,input().split()) map(int,input().split()) N node=2**N 2**N node cost=[] [] cost key=[] [] key k=node-1-j node-1-j k a,b=map(int,input().split()) map(int,input().split()) a dp=[[10**10 for i in range(0,node)] for j in range(0,M)] [[10**10 for i in range(0,node)] for j in range(0,M)] dp M=map(int,input().split()) map(int,input().split()) M b=map(int,input().split()) map(int,input().split()) b
N,M=map(int,input().split())
key=[]
cost=[]
for i in range(0,M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    s=sum(2**(c[j]-1) for j in range(0,b))
    key.append(s)
    cost.append(a)

node=2**N

dp=[[10**10 for i in range(0,node)] for j in range(0,M)]

for i in range(0,M):
    dp[i][node-1]=0
#i:何番までか j:手に入れた鍵
for i in range(0,M):
    for j in range(1,node):
        k=node-1-j
        if i==0:
            if k|key[0]==node-1:
                dp[0][k]=cost[0]
        else:
            dp[i][k]=min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i])

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