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

INF = 1001001001
dp = [INF] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for k, v in keys:
        t = s | k
        cost = dp[s] + v
        dp[t] = min(dp[t], cost)

ans = dp[-1]
if ans == INF: ans = -1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m keys = [] keys [] for i in range(m):
    a, b = map(int, input().split())
    s = 0
    for c in map(int, input().split()):
        c -= 1
        s |= 1 << c
    keys.append((s, a)) i 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 map(int, input().split()):
        c -= 1
        s |= 1 << c
     c map(int, input().split()) map int input().split() ().split () input split c -= 1 c 1 s |= 1 << c s 1 << c 1 c keys.append((s, a)) keys.append keys append (s, a) s a INF = 1001001001 INF 1001001001 dp = [INF] * (1<<n) dp [INF] * (1<<n) [INF] INF 1<<n 1 n dp[0] = 0 dp[0] dp 0 0 for s in range(1<<n):
    for k, v in keys:
        t = s | k
        cost = dp[s] + v
        dp[t] = min(dp[t], cost) s range(1<<n) range 1<<n 1 n for k, v in keys:
        t = s | k
        cost = dp[s] + v
        dp[t] = min(dp[t], cost) k v keys t = s | k t s | k s k cost = dp[s] + v cost dp[s] + v dp[s] dp s v dp[t] = min(dp[t], cost) dp[t] dp t min(dp[t], cost) min dp[t] dp t cost ans = dp[-1] ans dp[-1] dp -1 if ans == INF: ans = -1 ans == INF ans INF print(ans) print ans dp = [INF] * (1<<n) [INF] * (1<<n) dp ans = dp[-1] dp[-1] ans n, m = map(int, input().split()) map(int, input().split()) n a, b = map(int, input().split()) map(int, input().split()) a t = s | k s | k t s |= 1 << c 1 << c s INF = 1001001001 1001001001 INF keys = [] [] keys m = map(int, input().split()) map(int, input().split()) m cost = dp[s] + v dp[s] + v cost s = 0 0 s c -= 1 1 c b = map(int, input().split()) map(int, input().split()) b
n, m = map(int, input().split())
keys = []
for i in range(m):
    a, b = map(int, input().split())
    s = 0
    for c in map(int, input().split()):
        c -= 1
        s |= 1 << c
    keys.append((s, a))

INF = 1001001001
dp = [INF] * (1<<n)
dp[0] = 0
for s in range(1<<n):
    for k, v in keys:
        t = s | k
        cost = dp[s] + v
        dp[t] = min(dp[t], cost)

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