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

abc = []



for i in range(M):

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

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

  x = 0

  for j in k:

    x += (1 << (j - 1))

  abc.append(t + [x])



def nasu(n):

  ans = inf

  for i in range(1, n - 1):

    if ~n & i == 0:

      ans = min(ans, L[i] + L[n ^ i])

  return ans



inf = 10 ** 10

L = [inf] * (1 << N)



for i in range(1, N + 1):

  n = (1 << i) - 1

  while n < (1 << N):

    for j in range(M):

      if ~abc[j][2] & n == 0:

        L[n] = min(L[n], abc[j][0])

    L[n] = min(L[n], nasu(n))

    x = n & -n

    y = n + x

    n = ((n & ~y) // x >> 1) | y



if L[-1] == inf:

  print((-1))

else:

  print((L[-1]))



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

ab = []

c = []

for i in range(M):

  ab.append(list(map(int, input().split())))

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



A = [10 ** 10] * (1 << N)

C = []

for i in range(M):

  t = 0

  cc = c[i]

  a, b = ab[i]

  for j in cc:

    t |= 1 << (j - 1)

  C.append([t, a])

  A[t] = min(A[t], a)



for i in range(1, N + 1):

  n = (1 << i) - 1

  while n < (1 << N):

    for j in range(M):

      k, a = n | C[j][0], C[j][1]

      A[k] = min(A[k], A[n] + a)

    x = n & -n

    y = n + x

    n = ((n & ~y) // x >> 1) | y



if A[-1] == 10 ** 10:

  print((-1))

else:

  print((A[-1]))



N, M = list(map(int, input().split()))
abc = []
for i in range(M):
    t = list(map(int, input().split()))
    k = list(map(int, input().split()))
    x = 0
    for j in k:
        x += 1 << (j - 1)
    abc.append(t + [x])


def nasu(n):
    ans = inf
    for i in range(1, n - 1):
        if ~n & i == 0:
            ans = min(ans, L[i] + L[n ^ i])
    return ans


inf = 10**10
L = [inf] * (1 << N)
for i in range(1, N + 1):
    n = (1 << i) - 1
    while n < (1 << N):
        for j in range(M):
            if ~abc[j][2] & n == 0:
                L[n] = min(L[n], abc[j][0])
        L[n] = min(L[n], nasu(n))
        x = n & -n
        y = n + x
        n = ((n & ~y) // x >> 1) | y
if L[-1] == inf:
    print((-1))
else:
    print((L[-1]))

N, M = list(map(int, input().split()))
ab = []
c = []
for i in range(M):
    ab.append(list(map(int, input().split())))
    c.append(list(map(int, input().split())))
A = [10**10] * (1 << N)
C = []
for i in range(M):
    t = 0
    cc = c[i]
    a, b = ab[i]
    for j in cc:
        t |= 1 << (j - 1)
    C.append([t, a])
    A[t] = min(A[t], a)
for i in range(1, N + 1):
    n = (1 << i) - 1
    while n < (1 << N):
        for j in range(M):
            k, a = n | C[j][0], C[j][1]
            A[k] = min(A[k], A[n] + a)
        x = n & -n
        y = n + x
        n = ((n & ~y) // x >> 1) | y
if A[-1] == 10**10:
    print((-1))
else:
    print((A[-1]))

-abc = [] +ab = [] +c = [] -    t = list(map(int, input().split())) -    k = list(map(int, input().split())) -    x = 0 -    for j in k: -        x += 1 << (j - 1) -    abc.append(t + [x]) - - -def nasu(n): -    ans = inf -    for i in range(1, n - 1): -        if ~n & i == 0: -            ans = min(ans, L[i] + L[n ^ i]) -    return ans - - -inf = 10**10 -L = [inf] * (1 << N) +    ab.append(list(map(int, input().split()))) +    c.append(list(map(int, input().split()))) +A = [10**10] * (1 << N) +C = [] +for i in range(M): +    t = 0 +    cc = c[i] +    a, b = ab[i] +    for j in cc: +        t |= 1 << (j - 1) +    C.append([t, a]) +    A[t] = min(A[t], a) -            if ~abc[j][2] & n == 0: -                L[n] = min(L[n], abc[j][0]) -        L[n] = min(L[n], nasu(n)) +            k, a = n | C[j][0], C[j][1] +            A[k] = min(A[k], A[n] + a) -if L[-1] == inf: +if A[-1] == 10**10: -    print((L[-1])) +    print((A[-1]))