n,m=map(int,input().split())
L=2**n
cost=[0]+[10**8 for i in range(L-1)]

for i in range(m):
    a,b=map(int,input().split())
    c=sum([2**(int(i)-1) for i in input().split()])
    for j in range(L):
        q=j|c
        x=cost[j]+a
        if cost[q]>x:
            cost[q]=x
print(cost[L-1] if cost[L-1]<10**8 else -1) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m L=2**n L 2**n 2 n 10**8 for i in range(L-1) for i in range(L-1) i range(L-1) range L-1 L 1 for i in range(L-1) 10**8 10 8 cost=[0]+[10**8 for i in range(L-1)] cost [0]+[10**8 for i in range(L-1)] [0] 0 [10**8 for i in range(L-1)] for i in range(m):
    a,b=map(int,input().split())
    c=sum([2**(int(i)-1) for i in input().split()])
    for j in range(L):
        q=j|c
        x=cost[j]+a
        if cost[q]>x:
            cost[q]=x i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b 2**(int(i)-1) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() 2**(int(i)-1) 2 int(i)-1 int(i) int i 1 c=sum([2**(int(i)-1) for i in input().split()]) c sum([2**(int(i)-1) for i in input().split()]) sum [2**(int(i)-1) for i in input().split()] for j in range(L):
        q=j|c
        x=cost[j]+a
        if cost[q]>x:
            cost[q]=x j range(L) range L q=j|c q j|c j c x=cost[j]+a x cost[j]+a cost[j] cost j a if cost[q]>x:
            cost[q]=x cost[q]>x cost[q] cost q x cost[q]=x cost[q] cost q x print(cost[L-1] if cost[L-1]<10**8 else -1) print cost[L-1] if cost[L-1]<10**8 else -1 cost[L-1]<10**8 cost[L-1] cost L-1 L 1 10**8 10 8 cost[L-1] cost L-1 L 1 -1 x=cost[j]+a cost[j]+a x a,b=map(int,input().split()) map(int,input().split()) a b=map(int,input().split()) map(int,input().split()) b cost=[0]+[10**8 for i in range(L-1)] [0]+[10**8 for i in range(L-1)] cost L=2**n 2**n L n,m=map(int,input().split()) map(int,input().split()) n c=sum([2**(int(i)-1) for i in input().split()]) sum([2**(int(i)-1) for i in input().split()]) c m=map(int,input().split()) map(int,input().split()) m q=j|c j|c q
n,m=map(int,input().split())
L=2**n
cost=[0]+[10**8 for i in range(L-1)]

for i in range(m):
    a,b=map(int,input().split())
    c=sum([2**(int(i)-1) for i in input().split()])
    for j in range(L):
        q=j|c
        x=cost[j]+a
        if cost[q]>x:
            cost[q]=x
print(cost[L-1] if cost[L-1]<10**8 else -1)