n, m = map(int, input().split())
INF = 10 ** 5 * 12
dp = [INF] * (1 << n)
dp[0] = 0
keys = []

for _ in range(m):
    a, b = map(int, input().split())
    s = 0
    for c in list(map(int, input().split())):
        s |= 1 << (c - 1)
    keys.append([s, a])

for s in range(1 << n):
    for i in range(m):
        to = s | keys[i][0]
        cost = dp[s] + keys[i][1]
        dp[to] = min(dp[to], cost)

ans = dp[-1] if dp[-1] != INF else -1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m INF = 10 ** 5 * 12 INF 10 ** 5 * 12 10 ** 5 10 5 12 dp = [INF] * (1 << n) dp [INF] * (1 << n) [INF] INF 1 << n 1 n dp[0] = 0 dp[0] dp 0 0 keys = [] keys [] for _ in range(m):
    a, b = map(int, input().split())
    s = 0
    for c in list(map(int, input().split())):
        s |= 1 << (c - 1)
    keys.append([s, a]) _ range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b s = 0 s 0 for c in list(map(int, input().split())):
        s |= 1 << (c - 1)
     c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s |= 1 << (c - 1) s 1 << (c - 1) 1 c - 1 c 1 keys.append([s, a]) keys.append keys append [s, a] s a for s in range(1 << n):
    for i in range(m):
        to = s | keys[i][0]
        cost = dp[s] + keys[i][1]
        dp[to] = min(dp[to], cost) s range(1 << n) range 1 << n 1 n for i in range(m):
        to = s | keys[i][0]
        cost = dp[s] + keys[i][1]
        dp[to] = min(dp[to], cost) i range(m) range m to = s | keys[i][0] to s | keys[i][0] s keys[i][0] [i] keys i 0 cost = dp[s] + keys[i][1] cost dp[s] + keys[i][1] dp[s] dp s keys[i][1] [i] keys i 1 dp[to] = min(dp[to], cost) dp[to] dp to min(dp[to], cost) min dp[to] dp to cost ans = dp[-1] if dp[-1] != INF else -1 ans dp[-1] if dp[-1] != INF else -1 dp[-1] != INF dp[-1] dp -1 INF dp[-1] dp -1 -1 print(ans) print ans n, m = map(int, input().split()) map(int, input().split()) n dp = [INF] * (1 << n) [INF] * (1 << n) dp INF = 10 ** 5 * 12 10 ** 5 * 12 INF cost = dp[s] + keys[i][1] dp[s] + keys[i][1] cost a, b = map(int, input().split()) map(int, input().split()) a m = map(int, input().split()) map(int, input().split()) m s |= 1 << (c - 1) 1 << (c - 1) s keys = [] [] keys b = map(int, input().split()) map(int, input().split()) b s = 0 0 s to = s | keys[i][0] s | keys[i][0] to ans = dp[-1] if dp[-1] != INF else -1 dp[-1] if dp[-1] != INF else -1 ans
n, m = map(int, input().split())
INF = 10 ** 5 * 12
dp = [INF] * (1 << n)
dp[0] = 0
keys = []

for _ in range(m):
    a, b = map(int, input().split())
    s = 0
    for c in list(map(int, input().split())):
        s |= 1 << (c - 1)
    keys.append([s, a])

for s in range(1 << n):
    for i in range(m):
        to = s | keys[i][0]
        cost = dp[s] + keys[i][1]
        dp[to] = min(dp[to], cost)

ans = dp[-1] if dp[-1] != INF else -1
print(ans)
