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

