# 解説AC
# 参考1: https://drken1215.hatenablog.com/entry/2019/09/29/103500
# 参考2: https://www.slideshare.net/chokudai/wap-atcoder4


n, m = map(int, input().split())
A, B, C = [], [], []
for _ in range(m):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    c = list(map(int, input().split()))
    now = 0
    for i in range(b-1, -1, -1):
        now += 2**(c[i]-1)
    C.append(now)

INF = 10**9
DP = [[INF for _ in range(2**n)] for _ in range(m+1)]
DP[0][0] = 0

for i in range(m):
    for j in range(2**n):
        c = C[i]
        # 鍵を使用しない
        DP[i+1][j] = min(DP[i][j], DP[i+1][j])
        # 鍵を使用する
        nex = j | c
        DP[i+1][nex] = min(DP[i+1][nex], DP[i][j]+A[i])

ans = 10**9
for i in range(m):
    ans = min(DP[i][-1], ans)

if ans == 10**9:
    ans = -1

print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m A, B, C = [], [], [] A [] B [] C [] for _ in range(m):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    c = list(map(int, input().split()))
    now = 0
    for i in range(b-1, -1, -1):
        now += 2**(c[i]-1)
    C.append(now) _ range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b A.append(a) A.append A append a B.append(b) B.append B append 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 now = 0 now 0 for i in range(b-1, -1, -1):
        now += 2**(c[i]-1)
     i range(b-1, -1, -1) range b-1 b 1 -1 -1 now += 2**(c[i]-1) now 2**(c[i]-1) 2 c[i]-1 c[i] c i 1 C.append(now) C.append C append now INF = 10**9 INF 10**9 10 9 [INF for _ in range(2**n)] for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [INF for _ in range(2**n)] DP = [[INF for _ in range(2**n)] for _ in range(m+1)] DP [[INF for _ in range(2**n)] for _ in range(m+1)] DP[0][0] = 0 DP[0][0] [0] DP 0 0 0 for i in range(m):
    for j in range(2**n):
        c = C[i]
        # 鍵を使用しない
        DP[i+1][j] = min(DP[i][j], DP[i+1][j])
        # 鍵を使用する
        nex = j | c
        DP[i+1][nex] = min(DP[i+1][nex], DP[i][j]+A[i]) i range(m) range m for j in range(2**n):
        c = C[i]
        # 鍵を使用しない
        DP[i+1][j] = min(DP[i][j], DP[i+1][j])
        # 鍵を使用する
        nex = j | c
        DP[i+1][nex] = min(DP[i+1][nex], DP[i][j]+A[i]) j range(2**n) range 2**n 2 n c = C[i] c C[i] C i DP[i+1][j] = min(DP[i][j], DP[i+1][j]) DP[i+1][j] [i+1] DP i+1 i 1 j min(DP[i][j], DP[i+1][j]) min DP[i][j] [i] DP i j DP[i+1][j] [i+1] DP i+1 i 1 j nex = j | c nex j | c j c DP[i+1][nex] = min(DP[i+1][nex], DP[i][j]+A[i]) DP[i+1][nex] [i+1] DP i+1 i 1 nex min(DP[i+1][nex], DP[i][j]+A[i]) min DP[i+1][nex] [i+1] DP i+1 i 1 nex DP[i][j]+A[i] DP[i][j] [i] DP i j A[i] A i ans = 10**9 ans 10**9 10 9 for i in range(m):
    ans = min(DP[i][-1], ans) i range(m) range m ans = min(DP[i][-1], ans) ans min(DP[i][-1], ans) min DP[i][-1] [i] DP i -1 ans if ans == 10**9:
    ans = -1 ans == 10**9 ans 10**9 10 9 ans = -1 ans -1 print(ans) print ans A, B, C = [], [], [] [] A now = 0 0 now INF = 10**9 10**9 INF nex = j | c j | c nex b = map(int, input().split()) map(int, input().split()) b c = list(map(int, input().split())) list(map(int, input().split())) c DP = [[INF for _ in range(2**n)] for _ in range(m+1)] [[INF for _ in range(2**n)] for _ in range(m+1)] DP a, b = map(int, input().split()) map(int, input().split()) a C = [], [], [] [] C ans = 10**9 10**9 ans B, C = [], [], [] [] B now += 2**(c[i]-1) 2**(c[i]-1) now ans = -1 -1 ans m = map(int, input().split()) map(int, input().split()) m ans = min(DP[i][-1], ans) min(DP[i][-1], ans) ans n, m = map(int, input().split()) map(int, input().split()) n c = C[i] C[i] c
# 解説AC
# 参考1: https://drken1215.hatenablog.com/entry/2019/09/29/103500
# 参考2: https://www.slideshare.net/chokudai/wap-atcoder4


n, m = map(int, input().split())
A, B, C = [], [], []
for _ in range(m):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    c = list(map(int, input().split()))
    now = 0
    for i in range(b-1, -1, -1):
        now += 2**(c[i]-1)
    C.append(now)

INF = 10**9
DP = [[INF for _ in range(2**n)] for _ in range(m+1)]
DP[0][0] = 0

for i in range(m):
    for j in range(2**n):
        c = C[i]
        # 鍵を使用しない
        DP[i+1][j] = min(DP[i][j], DP[i+1][j])
        # 鍵を使用する
        nex = j | c
        DP[i+1][nex] = min(DP[i+1][nex], DP[i][j]+A[i])

ans = 10**9
for i in range(m):
    ans = min(DP[i][-1], ans)

if ans == 10**9:
    ans = -1

print(ans)