import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = []
for i in range(m):
    a, b = map(int, input().split())
    tmpc = map(int, input().split())
    c = sum(1 << (ci - 1) for ci in tmpc)
    ac.append((a, c))

# 解説AC
dp = [[0] + [pow(10, 9)] * (pow(2, n) - 1)]
for i, (ai, ci) in enumerate(ac, 1):
    dp.append(dp[-1][:])
    for j in range(pow(2, n)):
        tmp = min(dp[i - 1][j | ci], dp[i - 1][j] + ai)
        dp[i][j | ci] = min(tmp, dp[i][j | ci])
print(-1 if dp[-1][-1] == pow(10, 9) else dp[-1][-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 ac = [] ac [] for i in range(m):
    a, b = map(int, input().split())
    tmpc = map(int, input().split())
    c = sum(1 << (ci - 1) for ci in tmpc)
    ac.append((a, c))

# 解説AC i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b tmpc = map(int, input().split()) tmpc map(int, input().split()) map int input().split() ().split () input split c = sum(1 << (ci - 1) for ci in tmpc) c sum(1 << (ci - 1) for ci in tmpc) sum 1 << (ci - 1) 1 ci - 1 ci 1 ac.append((a, c)) ac.append ac append (a, c) a c dp = [[0] + [pow(10, 9)] * (pow(2, n) - 1)] dp [[0] + [pow(10, 9)] * (pow(2, n) - 1)] [0] + [pow(10, 9)] * (pow(2, n) - 1) [0] 0 [pow(10, 9)] * (pow(2, n) - 1) [pow(10, 9)] pow(10, 9) pow 10 9 pow(2, n) - 1 pow(2, n) pow 2 n 1 for i, (ai, ci) in enumerate(ac, 1):
    dp.append(dp[-1][:])
    for j in range(pow(2, n)):
        tmp = min(dp[i - 1][j | ci], dp[i - 1][j] + ai)
        dp[i][j | ci] = min(tmp, dp[i][j | ci]) i (ai, ci) ai ci enumerate(ac, 1) enumerate ac 1 dp.append(dp[-1][:]) dp.append dp append dp[-1][:] [-1] dp -1 : for j in range(pow(2, n)):
        tmp = min(dp[i - 1][j | ci], dp[i - 1][j] + ai)
        dp[i][j | ci] = min(tmp, dp[i][j | ci]) j range(pow(2, n)) range pow(2, n) pow 2 n tmp = min(dp[i - 1][j | ci], dp[i - 1][j] + ai) tmp min(dp[i - 1][j | ci], dp[i - 1][j] + ai) min dp[i - 1][j | ci] [i - 1] dp i - 1 i 1 j | ci j ci dp[i - 1][j] + ai dp[i - 1][j] [i - 1] dp i - 1 i 1 j ai dp[i][j | ci] = min(tmp, dp[i][j | ci]) dp[i][j | ci] [i] dp i j | ci j ci min(tmp, dp[i][j | ci]) min tmp dp[i][j | ci] [i] dp i j | ci j ci print(-1 if dp[-1][-1] == pow(10, 9) else dp[-1][-1]) print -1 if dp[-1][-1] == pow(10, 9) else dp[-1][-1] dp[-1][-1] == pow(10, 9) dp[-1][-1] [-1] dp -1 -1 pow(10, 9) pow 10 9 -1 dp[-1][-1] [-1] dp -1 -1 ac = [] [] ac input = sys.stdin.readline sys.stdin.readline input m = map(int, input().split()) map(int, input().split()) m c = sum(1 << (ci - 1) for ci in tmpc) sum(1 << (ci - 1) for ci in tmpc) c n, m = map(int, input().split()) map(int, input().split()) n tmpc = map(int, input().split()) map(int, input().split()) tmpc tmp = min(dp[i - 1][j | ci], dp[i - 1][j] + ai) min(dp[i - 1][j | ci], dp[i - 1][j] + ai) tmp b = map(int, input().split()) map(int, input().split()) b a, b = map(int, input().split()) map(int, input().split()) a dp = [[0] + [pow(10, 9)] * (pow(2, n) - 1)] [[0] + [pow(10, 9)] * (pow(2, n) - 1)] dp
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
ac = []
for i in range(m):
    a, b = map(int, input().split())
    tmpc = map(int, input().split())
    c = sum(1 << (ci - 1) for ci in tmpc)
    ac.append((a, c))

# 解説AC
dp = [[0] + [pow(10, 9)] * (pow(2, n) - 1)]
for i, (ai, ci) in enumerate(ac, 1):
    dp.append(dp[-1][:])
    for j in range(pow(2, n)):
        tmp = min(dp[i - 1][j | ci], dp[i - 1][j] + ai)
        dp[i][j | ci] = min(tmp, dp[i][j | ci])
print(-1 if dp[-1][-1] == pow(10, 9) else dp[-1][-1])