

N, M = list(map(int, input().split()))



C = [float('inf')] * (1 << N)

C[0] = 0

key_v = [float('inf')] * (1 << N)

for j in range(M):

    a, b = list(map(int, input().split()))

    box = list(map(int, input().split()))

    ex_status = 0

    for j in box:

        ex_status += 1 << (j-1)

    key_v[ex_status] = min(a, key_v[ex_status])



for key, val in enumerate(key_v):

    if val == float('inf'):

        continue

    for i in range(1 << N):

        now_status = i

        score = C[now_status] + val

        if score == float("inf"):

            continue



        now_status = i | key



        if C[now_status] > score:

            C[now_status] = score



if C[-1] == float("inf"):

    print((-1))

else:

    print((C[-1]))



N, M = list(map(int, input().split()))

A = []

min_state = [10**9] * (2**N)

min_state[0] = 0

for _ in range(M):

    a, b = list(map(int, input().split()))

    c = list(map(int, input().split()))

    key = 0

    for tmp in c:

        key += 2**(tmp-1)

    A.append((a, key))

L = len(min_state)

for a, key in A:

    for i, score in enumerate(min_state):

        next_key = key | i



        if min_state[next_key] > score + a:

            min_state[next_key] = score + a

if min_state[-1] == 10**9:

    print((-1))

else:

    print((min_state[-1]))



N, M = list(map(int, input().split()))
C = [float("inf")] * (1 << N)
C[0] = 0
key_v = [float("inf")] * (1 << N)
for j in range(M):
    a, b = list(map(int, input().split()))
    box = list(map(int, input().split()))
    ex_status = 0
    for j in box:
        ex_status += 1 << (j - 1)
    key_v[ex_status] = min(a, key_v[ex_status])
for key, val in enumerate(key_v):
    if val == float("inf"):
        continue
    for i in range(1 << N):
        now_status = i
        score = C[now_status] + val
        if score == float("inf"):
            continue
        now_status = i | key
        if C[now_status] > score:
            C[now_status] = score
if C[-1] == float("inf"):
    print((-1))
else:
    print((C[-1]))

N, M = list(map(int, input().split()))
A = []
min_state = [10**9] * (2**N)
min_state[0] = 0
for _ in range(M):
    a, b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    key = 0
    for tmp in c:
        key += 2 ** (tmp - 1)
    A.append((a, key))
L = len(min_state)
for a, key in A:
    for i, score in enumerate(min_state):
        next_key = key | i
        if min_state[next_key] > score + a:
            min_state[next_key] = score + a
if min_state[-1] == 10**9:
    print((-1))
else:
    print((min_state[-1]))

-C = [float("inf")] * (1 << N) -C[0] = 0 -key_v = [float("inf")] * (1 << N) -for j in range(M): +A = [] +min_state = [10**9] * (2**N) +min_state[0] = 0 +for _ in range(M): -    box = list(map(int, input().split())) -    ex_status = 0 -    for j in box: -        ex_status += 1 << (j - 1) -    key_v[ex_status] = min(a, key_v[ex_status]) -for key, val in enumerate(key_v): -    if val == float("inf"): -        continue -    for i in range(1 << N): -        now_status = i -        score = C[now_status] + val -        if score == float("inf"): -            continue -        now_status = i | key -        if C[now_status] > score: -            C[now_status] = score -if C[-1] == float("inf"): +    c = list(map(int, input().split())) +    key = 0 +    for tmp in c: +        key += 2 ** (tmp - 1) +    A.append((a, key)) +L = len(min_state) +for a, key in A: +    for i, score in enumerate(min_state): +        next_key = key | i +        if min_state[next_key] > score + a: +            min_state[next_key] = score + a +if min_state[-1] == 10**9: -    print((C[-1])) +    print((min_state[-1]))