import math

N, M = list(map(int, input().split()))

keys = []

for i in range(M):
    a, b = list(map(int, input().split()))
    key_bit = 0
    c = list(map(int, input().split()))
    for j in range(b):
        key_bit |= 1 << (c[j] - 1)
    keys.append([a, key_bit])

dp = [math.inf]*(1 << N)

dp[0] = 0

for i in range(M):
    for j in range(1 << N):
        dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])

if dp[-1] == math.inf:
    dp[-1] = -1

print(dp[-1]) import math math N, M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M keys = [] keys [] for i in range(M):
    a, b = list(map(int, input().split()))
    key_bit = 0
    c = list(map(int, input().split()))
    for j in range(b):
        key_bit |= 1 << (c[j] - 1)
    keys.append([a, key_bit]) i range(M) range M a, b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split b key_bit = 0 key_bit 0 c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split for j in range(b):
        key_bit |= 1 << (c[j] - 1)
     j range(b) range b key_bit |= 1 << (c[j] - 1) key_bit 1 << (c[j] - 1) 1 c[j] - 1 c[j] c j 1 keys.append([a, key_bit]) keys.append keys append [a, key_bit] a key_bit dp = [math.inf]*(1 << N) dp [math.inf]*(1 << N) [math.inf] math.inf math inf 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    for j in range(1 << N):
        dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0]) i range(M) range M for j in range(1 << N):
        dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0]) j range(1 << N) range 1 << N 1 N dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0]) dp[j | keys[i][1]] dp j | keys[i][1] j keys[i][1] [i] keys i 1 min(dp[j | keys[i][1]], dp[j] + keys[i][0]) min dp[j | keys[i][1]] dp j | keys[i][1] j keys[i][1] [i] keys i 1 dp[j] + keys[i][0] dp[j] dp j keys[i][0] [i] keys i 0 if dp[-1] == math.inf:
    dp[-1] = -1 dp[-1] == math.inf dp[-1] dp -1 math.inf math inf dp[-1] = -1 dp[-1] dp -1 -1 print(dp[-1]) print dp[-1] dp -1 keys = [] [] keys a, b = list(map(int, input().split())) list(map(int, input().split())) a key_bit = 0 0 key_bit N, M = list(map(int, input().split())) list(map(int, input().split())) N M = list(map(int, input().split())) list(map(int, input().split())) M b = list(map(int, input().split())) list(map(int, input().split())) b dp = [math.inf]*(1 << N) [math.inf]*(1 << N) dp key_bit |= 1 << (c[j] - 1) 1 << (c[j] - 1) key_bit c = list(map(int, input().split())) list(map(int, input().split())) c
import math

N, M = list(map(int, input().split()))

keys = []

for i in range(M):
    a, b = list(map(int, input().split()))
    key_bit = 0
    c = list(map(int, input().split()))
    for j in range(b):
        key_bit |= 1 << (c[j] - 1)
    keys.append([a, key_bit])

dp = [math.inf]*(1 << N)

dp[0] = 0

for i in range(M):
    for j in range(1 << N):
        dp[j | keys[i][1]] = min(dp[j | keys[i][1]], dp[j] + keys[i][0])

if dp[-1] == math.inf:
    dp[-1] = -1

print(dp[-1])
