INF = 10**9
n, m = map(int, input().split())
keys = []
for _ in range(m):
    a, _ = map(int, input().split())
    c = 0
    for i in input().split():
        c += 2**(int(i)-1)
    keys.append((a, c))

dp = [INF]*(2**n)
dp[0] = 0
for a, c in keys:
    tmp = [INF]*(2**n)
    for j, d in enumerate(dp):
        if d == INF:
            continue
        if d < tmp[j]:
            tmp[j] = d
        if d+a < tmp[j|c]:
            tmp[j|c] = d+a
    dp = tmp

print(dp[-1] if dp[-1]<INF else -1) INF = 10**9 INF 10**9 10 9 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m keys = [] keys [] for _ in range(m):
    a, _ = map(int, input().split())
    c = 0
    for i in input().split():
        c += 2**(int(i)-1)
    keys.append((a, c)) _ range(m) range m a, _ = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split _ c = 0 c 0 for i in input().split():
        c += 2**(int(i)-1)
     i input().split() ().split () input split c += 2**(int(i)-1) c 2**(int(i)-1) 2 int(i)-1 int(i) int i 1 keys.append((a, c)) keys.append keys append (a, c) a c dp = [INF]*(2**n) dp [INF]*(2**n) [INF] INF 2**n 2 n dp[0] = 0 dp[0] dp 0 0 for a, c in keys:
    tmp = [INF]*(2**n)
    for j, d in enumerate(dp):
        if d == INF:
            continue
        if d < tmp[j]:
            tmp[j] = d
        if d+a < tmp[j|c]:
            tmp[j|c] = d+a
    dp = tmp a c keys tmp = [INF]*(2**n) tmp [INF]*(2**n) [INF] INF 2**n 2 n for j, d in enumerate(dp):
        if d == INF:
            continue
        if d < tmp[j]:
            tmp[j] = d
        if d+a < tmp[j|c]:
            tmp[j|c] = d+a
     j d enumerate(dp) enumerate dp if d == INF:
            continue
         d == INF d INF continue if d < tmp[j]:
            tmp[j] = d
         d < tmp[j] d tmp[j] tmp j tmp[j] = d tmp[j] tmp j d if d+a < tmp[j|c]:
            tmp[j|c] = d+a
     d+a < tmp[j|c] d+a d a tmp[j|c] tmp j|c j c tmp[j|c] = d+a tmp[j|c] tmp j|c j c d+a d a dp = tmp dp tmp print(dp[-1] if dp[-1]<INF else -1) print dp[-1] if dp[-1]<INF else -1 dp[-1]<INF dp[-1] dp -1 INF dp[-1] dp -1 -1 _ = map(int, input().split()) map(int, input().split()) _ c += 2**(int(i)-1) 2**(int(i)-1) c n, m = map(int, input().split()) map(int, input().split()) n dp = tmp tmp dp dp = [INF]*(2**n) [INF]*(2**n) dp INF = 10**9 10**9 INF a, _ = map(int, input().split()) map(int, input().split()) a c = 0 0 c keys = [] [] keys m = map(int, input().split()) map(int, input().split()) m tmp = [INF]*(2**n) [INF]*(2**n) tmp
INF = 10**9
n, m = map(int, input().split())
keys = []
for _ in range(m):
    a, _ = map(int, input().split())
    c = 0
    for i in input().split():
        c += 2**(int(i)-1)
    keys.append((a, c))

dp = [INF]*(2**n)
dp[0] = 0
for a, c in keys:
    tmp = [INF]*(2**n)
    for j, d in enumerate(dp):
        if d == INF:
            continue
        if d < tmp[j]:
            tmp[j] = d
        if d+a < tmp[j|c]:
            tmp[j|c] = d+a
    dp = tmp

print(dp[-1] if dp[-1]<INF else -1)
