import sys
input=sys.stdin.readline
n, m = map(int, input().split())
A = [0] * m
B = [0] * m
C = [[] for _ in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b
    c = list(map(int, input().split()))
    C[i] = c
D = [0] * m
for i in range(m):
    d = 0
    for j in C[i]:
        d |= 1 << (j - 1)
    D[i] = d
# dp[i][s], i番目までの鍵を使ってSを作る最小コスト
infi = 10 ** 20
dp = [[infi for i in range(2 ** n + 1)] for _ in range(m + 1)]
dp[0][0] = 0
for i in range(m):
    for s in range(2 ** n):
        ni = i + 1
        ns = s
        # 使わないとき
        dp[ni][ns] = min(dp[i][s], dp[ni][ns])
        # 使うとき
        ns = s | D[i]
        dp[ni][ns] = min(dp[ni][ns], dp[i][s] + A[i])
ans = dp[m][2 ** n - 1]
print(ans if ans < infi else -1) import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m A = [0] * m A [0] * m [0] 0 m B = [0] * m B [0] * m [0] 0 m [] for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [] C = [[] for _ in range(m)] C [[] for _ in range(m)] for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b
    c = list(map(int, input().split()))
    C[i] = c i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A[i] = a A[i] A i a B[i] = b B[i] B i 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 C[i] = c C[i] C i c D = [0] * m D [0] * m [0] 0 m for i in range(m):
    d = 0
    for j in C[i]:
        d |= 1 << (j - 1)
    D[i] = d
# dp[i][s], i番目までの鍵を使ってSを作る最小コスト i range(m) range m d = 0 d 0 for j in C[i]:
        d |= 1 << (j - 1)
     j C[i] C i d |= 1 << (j - 1) d 1 << (j - 1) 1 j - 1 j 1 D[i] = d D[i] D i d infi = 10 ** 20 infi 10 ** 20 10 20 [infi for i in range(2 ** n + 1)] for _ in range(m + 1) for _ in range(m + 1) _ range(m + 1) range m + 1 m 1 for _ in range(m + 1) [infi for i in range(2 ** n + 1)] dp = [[infi for i in range(2 ** n + 1)] for _ in range(m + 1)] dp [[infi for i in range(2 ** n + 1)] for _ in range(m + 1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    for s in range(2 ** n):
        ni = i + 1
        ns = s
        # 使わないとき
        dp[ni][ns] = min(dp[i][s], dp[ni][ns])
        # 使うとき
        ns = s | D[i]
        dp[ni][ns] = min(dp[ni][ns], dp[i][s] + A[i]) i range(m) range m for s in range(2 ** n):
        ni = i + 1
        ns = s
        # 使わないとき
        dp[ni][ns] = min(dp[i][s], dp[ni][ns])
        # 使うとき
        ns = s | D[i]
        dp[ni][ns] = min(dp[ni][ns], dp[i][s] + A[i]) s range(2 ** n) range 2 ** n 2 n ni = i + 1 ni i + 1 i 1 ns = s ns s dp[ni][ns] = min(dp[i][s], dp[ni][ns]) dp[ni][ns] [ni] dp ni ns min(dp[i][s], dp[ni][ns]) min dp[i][s] [i] dp i s dp[ni][ns] [ni] dp ni ns ns = s | D[i] ns s | D[i] s D[i] D i dp[ni][ns] = min(dp[ni][ns], dp[i][s] + A[i]) dp[ni][ns] [ni] dp ni ns min(dp[ni][ns], dp[i][s] + A[i]) min dp[ni][ns] [ni] dp ni ns dp[i][s] + A[i] dp[i][s] [i] dp i s A[i] A i ans = dp[m][2 ** n - 1] ans dp[m][2 ** n - 1] [m] dp m 2 ** n - 1 2 ** n 2 n 1 print(ans if ans < infi else -1) print ans if ans < infi else -1 ans < infi ans infi ans -1 B = [0] * m [0] * m B d = 0 0 d a, b = map(int, input().split()) map(int, input().split()) a ns = s | D[i] s | D[i] ns ni = i + 1 i + 1 ni input=sys.stdin.readline sys.stdin.readline input c = list(map(int, input().split())) list(map(int, input().split())) c n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m C = [[] for _ in range(m)] [[] for _ in range(m)] C d |= 1 << (j - 1) 1 << (j - 1) d ns = s s ns dp = [[infi for i in range(2 ** n + 1)] for _ in range(m + 1)] [[infi for i in range(2 ** n + 1)] for _ in range(m + 1)] dp b = map(int, input().split()) map(int, input().split()) b D = [0] * m [0] * m D infi = 10 ** 20 10 ** 20 infi ans = dp[m][2 ** n - 1] dp[m][2 ** n - 1] ans A = [0] * m [0] * m A
import sys
input=sys.stdin.readline
n, m = map(int, input().split())
A = [0] * m
B = [0] * m
C = [[] for _ in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b
    c = list(map(int, input().split()))
    C[i] = c
D = [0] * m
for i in range(m):
    d = 0
    for j in C[i]:
        d |= 1 << (j - 1)
    D[i] = d
# dp[i][s], i番目までの鍵を使ってSを作る最小コスト
infi = 10 ** 20
dp = [[infi for i in range(2 ** n + 1)] for _ in range(m + 1)]
dp[0][0] = 0
for i in range(m):
    for s in range(2 ** n):
        ni = i + 1
        ns = s
        # 使わないとき
        dp[ni][ns] = min(dp[i][s], dp[ni][ns])
        # 使うとき
        ns = s | D[i]
        dp[ni][ns] = min(dp[ni][ns], dp[i][s] + A[i])
ans = dp[m][2 ** n - 1]
print(ans if ans < infi else -1)
