n, m = map(int, input().split())
keys = dict()
min_cost = dict()
for i in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for x in c:
        bit |= 1 << (x - 1)
    if bit in keys and keys[bit] <= a:
        continue
    keys[bit] = a
    min_cost[bit] = a

for i in range(1, 1 << n):
    if not i in min_cost:
        continue 
    for bit, cost in keys.items():
        bit |= i
        if i != bit:
            if bit in min_cost:
                min_cost[bit] = min(min_cost[bit], min_cost[i] + cost)
            else:
                min_cost[bit] = min_cost[i] + cost

if not (1 << n) - 1 in min_cost:
    print(-1)
else:
    print(min_cost[(1 << n) - 1]) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m keys = dict() keys dict() dict min_cost = dict() min_cost dict() dict for i in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for x in c:
        bit |= 1 << (x - 1)
    if bit in keys and keys[bit] <= a:
        continue
    keys[bit] = a
    min_cost[bit] = a i range(m) range 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 bit = 0 bit 0 for x in c:
        bit |= 1 << (x - 1)
     x c bit |= 1 << (x - 1) bit 1 << (x - 1) 1 x - 1 x 1 if bit in keys and keys[bit] <= a:
        continue
     bit in keys and keys[bit] <= a bit in keys bit keys keys[bit] <= a keys[bit] keys bit a continue keys[bit] = a keys[bit] keys bit a min_cost[bit] = a min_cost[bit] min_cost bit a for i in range(1, 1 << n):
    if not i in min_cost:
        continue 
    for bit, cost in keys.items():
        bit |= i
        if i != bit:
            if bit in min_cost:
                min_cost[bit] = min(min_cost[bit], min_cost[i] + cost)
            else:
                min_cost[bit] = min_cost[i] + cost i range(1, 1 << n) range 1 1 << n 1 n if not i in min_cost:
        continue 
     not i in min_cost i in min_cost i min_cost continue for bit, cost in keys.items():
        bit |= i
        if i != bit:
            if bit in min_cost:
                min_cost[bit] = min(min_cost[bit], min_cost[i] + cost)
            else:
                min_cost[bit] = min_cost[i] + cost bit cost keys.items() keys.items keys items bit |= i bit i if i != bit:
            if bit in min_cost:
                min_cost[bit] = min(min_cost[bit], min_cost[i] + cost)
            else:
                min_cost[bit] = min_cost[i] + cost i != bit i bit if bit in min_cost:
                min_cost[bit] = min(min_cost[bit], min_cost[i] + cost)
            else:
                min_cost[bit] = min_cost[i] + cost bit in min_cost bit min_cost min_cost[bit] = min(min_cost[bit], min_cost[i] + cost) min_cost[bit] min_cost bit min(min_cost[bit], min_cost[i] + cost) min min_cost[bit] min_cost bit min_cost[i] + cost min_cost[i] min_cost i cost min_cost[bit] = min_cost[i] + cost min_cost[bit] min_cost bit min_cost[i] + cost min_cost[i] min_cost i cost if not (1 << n) - 1 in min_cost:
    print(-1)
else:
    print(min_cost[(1 << n) - 1]) not (1 << n) - 1 in min_cost (1 << n) - 1 in min_cost (1 << n) - 1 1 << n 1 n 1 min_cost print(-1) print -1 print(min_cost[(1 << n) - 1]) print min_cost[(1 << n) - 1] min_cost (1 << n) - 1 1 << n 1 n 1 c = list(map(int, input().split())) list(map(int, input().split())) c bit = 0 0 bit min_cost = dict() dict() min_cost b = map(int, input().split()) map(int, input().split()) b n, m = map(int, input().split()) map(int, input().split()) n keys = dict() dict() keys bit |= 1 << (x - 1) 1 << (x - 1) bit a, b = map(int, input().split()) map(int, input().split()) a bit |= i i bit m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
keys = dict()
min_cost = dict()
for i in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for x in c:
        bit |= 1 << (x - 1)
    if bit in keys and keys[bit] <= a:
        continue
    keys[bit] = a
    min_cost[bit] = a

for i in range(1, 1 << n):
    if not i in min_cost:
        continue 
    for bit, cost in keys.items():
        bit |= i
        if i != bit:
            if bit in min_cost:
                min_cost[bit] = min(min_cost[bit], min_cost[i] + cost)
            else:
                min_cost[bit] = min_cost[i] + cost

if not (1 << n) - 1 in min_cost:
    print(-1)
else:
    print(min_cost[(1 << n) - 1])