def f(L):
    X=0
    for k in L:
        X+=2**(k-1)
    return X

N,M=map(int,input().split())
H=2**N
inf=float("inf")

DP=[inf for _ in range(H)]
DP[0]=0

for _ in range(M):
    A,B=map(int,input().split())
    C=f(list(map(int,input().split())))

    for k in range(H):
        DP[k|C]=min(DP[k|C],DP[k]+A)

if DP[-1]==inf:
    print(-1)
else:
    print(DP[-1]) def f(L):
    X=0
    for k in L:
        X+=2**(k-1)
    return X f X=0 X 0 for k in L:
        X+=2**(k-1)
     k L X+=2**(k-1) X 2**(k-1) 2 k-1 k 1 return X X L L N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M H=2**N H 2**N 2 N inf=float("inf") inf float("inf") float "inf" inf for _ in range(H) for _ in range(H) _ range(H) range H for _ in range(H) inf DP=[inf for _ in range(H)] DP [inf for _ in range(H)] DP[0]=0 DP[0] DP 0 0 for _ in range(M):
    A,B=map(int,input().split())
    C=f(list(map(int,input().split())))

    for k in range(H):
        DP[k|C]=min(DP[k|C],DP[k]+A) _ range(M) range M A,B=map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B C=f(list(map(int,input().split()))) C f(list(map(int,input().split()))) f list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for k in range(H):
        DP[k|C]=min(DP[k|C],DP[k]+A) k range(H) range H DP[k|C]=min(DP[k|C],DP[k]+A) DP[k|C] DP k|C k C min(DP[k|C],DP[k]+A) min DP[k|C] DP k|C k C DP[k]+A DP[k] DP k A if DP[-1]==inf:
    print(-1)
else:
    print(DP[-1]) DP[-1]==inf DP[-1] DP -1 inf print(-1) print -1 print(DP[-1]) print DP[-1] DP -1 DP=[inf for _ in range(H)] [inf for _ in range(H)] DP def f(L):
    X=0
    for k in L:
        X+=2**(k-1)
    return X def f(L):
    X=0
    for k in L:
        X+=2**(k-1)
    return X f N,M=map(int,input().split()) map(int,input().split()) N B=map(int,input().split()) map(int,input().split()) B inf=float("inf") float("inf") inf A,B=map(int,input().split()) map(int,input().split()) A H=2**N 2**N H M=map(int,input().split()) map(int,input().split()) M C=f(list(map(int,input().split()))) f(list(map(int,input().split()))) C
def f(L):
    X=0
    for k in L:
        X+=2**(k-1)
    return X

N,M=map(int,input().split())
H=2**N
inf=float("inf")

DP=[inf for _ in range(H)]
DP[0]=0

for _ in range(M):
    A,B=map(int,input().split())
    C=f(list(map(int,input().split())))

    for k in range(H):
        DP[k|C]=min(DP[k|C],DP[k]+A)

if DP[-1]==inf:
    print(-1)
else:
    print(DP[-1])