N, M = map(int, input().split())
Cost = []
Key = []
for i in range(M):
    a, b = map(int, input().split())
    Cost.append(a)
    C_ = list(map(int, input().split()))
    C = 0
    for c in C_:
        C |= (1 << (c - 1))
    Key.append(C)
DP = [float('inf')] * (1 << N)
DP[0] = 0

for cost, key in zip(Cost, Key):
    D = DP[:]
    for i, d in enumerate(DP):
        if d == float('inf'):
            continue
        D[i|key] = min(D[i|key], d + cost)
    DP = D

if DP[-1] == float('inf'):
    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 Cost = [] Cost [] Key = [] Key [] for i in range(M):
    a, b = map(int, input().split())
    Cost.append(a)
    C_ = list(map(int, input().split()))
    C = 0
    for c in C_:
        C |= (1 << (c - 1))
    Key.append(C) i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b Cost.append(a) Cost.append Cost append a C_ = list(map(int, input().split())) C_ list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split C = 0 C 0 for c in C_:
        C |= (1 << (c - 1))
     c C_ C |= (1 << (c - 1)) C 1 << (c - 1) 1 c - 1 c 1 Key.append(C) Key.append Key append C DP = [float('inf')] * (1 << N) DP [float('inf')] * (1 << N) [float('inf')] float('inf') float 'inf' 1 << N 1 N DP[0] = 0 DP[0] DP 0 0 for cost, key in zip(Cost, Key):
    D = DP[:]
    for i, d in enumerate(DP):
        if d == float('inf'):
            continue
        D[i|key] = min(D[i|key], d + cost)
    DP = D cost key zip(Cost, Key) zip Cost Key D = DP[:] D DP[:] DP : for i, d in enumerate(DP):
        if d == float('inf'):
            continue
        D[i|key] = min(D[i|key], d + cost)
     i d enumerate(DP) enumerate DP if d == float('inf'):
            continue
         d == float('inf') d float('inf') float 'inf' continue D[i|key] = min(D[i|key], d + cost) D[i|key] D i|key i key min(D[i|key], d + cost) min D[i|key] D i|key i key d + cost d cost DP = D DP D if DP[-1] == float('inf'):
    print(-1)
else:
    print(DP[-1]) DP[-1] == float('inf') DP[-1] DP -1 float('inf') float 'inf' print(-1) print -1 print(DP[-1]) print DP[-1] DP -1 C = 0 0 C DP = D D DP M = map(int, input().split()) map(int, input().split()) M a, b = map(int, input().split()) map(int, input().split()) a N, M = map(int, input().split()) map(int, input().split()) N Cost = [] [] Cost Key = [] [] Key C |= (1 << (c - 1)) 1 << (c - 1) C C_ = list(map(int, input().split())) list(map(int, input().split())) C_ DP = [float('inf')] * (1 << N) [float('inf')] * (1 << N) DP D = DP[:] DP[:] D b = map(int, input().split()) map(int, input().split()) b
N, M = map(int, input().split())
Cost = []
Key = []
for i in range(M):
    a, b = map(int, input().split())
    Cost.append(a)
    C_ = list(map(int, input().split()))
    C = 0
    for c in C_:
        C |= (1 << (c - 1))
    Key.append(C)
DP = [float('inf')] * (1 << N)
DP[0] = 0

for cost, key in zip(Cost, Key):
    D = DP[:]
    for i, d in enumerate(DP):
        if d == float('inf'):
            continue
        D[i|key] = min(D[i|key], d + cost)
    DP = D

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

