from heapq import heappop, heappush
def inpl(): return list(map(int, input().split()))
N, M = inpl()
A = [0]*M
B = [0]*M
C = [0]*M
for m in range(M):
    A[m], B[m] = inpl()
    c = 0
    for x in inpl():
        c += pow(2, x-1)
    C[m] = c
DP = [10**9]*pow(2, N)
DP[0] = 0
for i in range(pow(2, N)):
    if DP[i] > 10**8:
        continue
    for m in range(M):
        DP[i|C[m]] = min(DP[i|C[m]], DP[i] + A[m])
print(DP[-1] if DP[-1] < 10**9 else -1) from heapq import heappop, heappush def inpl(): return list(map(int, input().split())) inpl N, M = inpl() N inpl() inpl M A = [0]*M A [0]*M [0] 0 M B = [0]*M B [0]*M [0] 0 M C = [0]*M C [0]*M [0] 0 M for m in range(M):
    A[m], B[m] = inpl()
    c = 0
    for x in inpl():
        c += pow(2, x-1)
    C[m] = c m range(M) range M A[m], B[m] = inpl() A[m] A m inpl() inpl B[m] B m c = 0 c 0 for x in inpl():
        c += pow(2, x-1)
     x inpl() inpl c += pow(2, x-1) c pow(2, x-1) pow 2 x-1 x 1 C[m] = c C[m] C m c DP = [10**9]*pow(2, N) DP [10**9]*pow(2, N) [10**9] 10**9 10 9 pow(2, N) pow 2 N DP[0] = 0 DP[0] DP 0 0 for i in range(pow(2, N)):
    if DP[i] > 10**8:
        continue
    for m in range(M):
        DP[i|C[m]] = min(DP[i|C[m]], DP[i] + A[m]) i range(pow(2, N)) range pow(2, N) pow 2 N if DP[i] > 10**8:
        continue
     DP[i] > 10**8 DP[i] DP i 10**8 10 8 continue for m in range(M):
        DP[i|C[m]] = min(DP[i|C[m]], DP[i] + A[m]) m range(M) range M DP[i|C[m]] = min(DP[i|C[m]], DP[i] + A[m]) DP[i|C[m]] DP i|C[m] i C[m] C m min(DP[i|C[m]], DP[i] + A[m]) min DP[i|C[m]] DP i|C[m] i C[m] C m DP[i] + A[m] DP[i] DP i A[m] A m print(DP[-1] if DP[-1] < 10**9 else -1) print DP[-1] if DP[-1] < 10**9 else -1 DP[-1] < 10**9 DP[-1] DP -1 10**9 10 9 DP[-1] DP -1 -1 DP = [10**9]*pow(2, N) [10**9]*pow(2, N) DP M = inpl() inpl() M c = 0 0 c N, M = inpl() inpl() N C = [0]*M [0]*M C B = [0]*M [0]*M B A = [0]*M [0]*M A def inpl(): return list(map(int, input().split())) def inpl(): return list(map(int, input().split())) inpl c += pow(2, x-1) pow(2, x-1) c
from heapq import heappop, heappush
def inpl(): return list(map(int, input().split()))
N, M = inpl()
A = [0]*M
B = [0]*M
C = [0]*M
for m in range(M):
    A[m], B[m] = inpl()
    c = 0
    for x in inpl():
        c += pow(2, x-1)
    C[m] = c
DP = [10**9]*pow(2, N)
DP[0] = 0
for i in range(pow(2, N)):
    if DP[i] > 10**8:
        continue
    for m in range(M):
        DP[i|C[m]] = min(DP[i|C[m]], DP[i] + A[m])
print(DP[-1] if DP[-1] < 10**9 else -1)