from collections import defaultdict
INF = 10**13
N, M = map(int, input().split())
A = []
C = []
for m in range(M):
    a, b = map(int, input().split())
    A += [a]
    c = list(map(int, input().split()))
    C += [sum(map(lambda x: 2**(x-1), c))]
dp = [INF for i in range(2**N)]
dp[0] = 0
for i in range(2**N):
    for j in range(M):
        dp[i | C[j]] = min(dp[i] + A[j], dp[i | C[j]])

if dp[2**N-1] == INF:
    print(-1)
else:
    print(dp[2**N-1]) from collections import defaultdict INF = 10**13 INF 10**13 10 13 N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M A = [] A [] C = [] C [] for m in range(M):
    a, b = map(int, input().split())
    A += [a]
    c = list(map(int, input().split()))
    C += [sum(map(lambda x: 2**(x-1), c))] m range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A += [a] A [a] 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 += [sum(map(lambda x: 2**(x-1), c))] C [sum(map(lambda x: 2**(x-1), c))] sum(map(lambda x: 2**(x-1), c)) sum map(lambda x: 2**(x-1), c) map lambda x: 2**(x-1) 2**(x-1) 2 x-1 x 1 x c INF for i in range(2**N) for i in range(2**N) i range(2**N) range 2**N 2 N for i in range(2**N) INF dp = [INF for i in range(2**N)] dp [INF for i in range(2**N)] dp[0] = 0 dp[0] dp 0 0 for i in range(2**N):
    for j in range(M):
        dp[i | C[j]] = min(dp[i] + A[j], dp[i | C[j]]) i range(2**N) range 2**N 2 N for j in range(M):
        dp[i | C[j]] = min(dp[i] + A[j], dp[i | C[j]]) j range(M) range M dp[i | C[j]] = min(dp[i] + A[j], dp[i | C[j]]) dp[i | C[j]] dp i | C[j] i C[j] C j min(dp[i] + A[j], dp[i | C[j]]) min dp[i] + A[j] dp[i] dp i A[j] A j dp[i | C[j]] dp i | C[j] i C[j] C j if dp[2**N-1] == INF:
    print(-1)
else:
    print(dp[2**N-1]) dp[2**N-1] == INF dp[2**N-1] dp 2**N-1 2**N 2 N 1 INF print(-1) print -1 print(dp[2**N-1]) print dp[2**N-1] dp 2**N-1 2**N 2 N 1 a, b = map(int, input().split()) map(int, input().split()) a N, M = map(int, input().split()) map(int, input().split()) N C += [sum(map(lambda x: 2**(x-1), c))] [sum(map(lambda x: 2**(x-1), c))] C M = map(int, input().split()) map(int, input().split()) M c = list(map(int, input().split())) list(map(int, input().split())) c INF = 10**13 10**13 INF b = map(int, input().split()) map(int, input().split()) b A += [a] [a] A dp = [INF for i in range(2**N)] [INF for i in range(2**N)] dp A = [] [] A C = [] [] C
from collections import defaultdict
INF = 10**13
N, M = map(int, input().split())
A = []
C = []
for m in range(M):
    a, b = map(int, input().split())
    A += [a]
    c = list(map(int, input().split()))
    C += [sum(map(lambda x: 2**(x-1), c))]
dp = [INF for i in range(2**N)]
dp[0] = 0
for i in range(2**N):
    for j in range(M):
        dp[i | C[j]] = min(dp[i] + A[j], dp[i | C[j]])

if dp[2**N-1] == INF:
    print(-1)
else:
    print(dp[2**N-1])