N, M = map(int, input().split())
inf = int(1e10)
dp = [inf] * (1 << N) #1をNだけシフトする 2**B

#鍵をビットで表す　dp[i]は鍵の状態iにできる最小費用を
dp[0] = 0
bits = set()
bits.add(0)

for i in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    # cを状態keyに変換
    key = 0
    for t in c:
        key += 1 << (t - 1)
    # bits内のbitとkeyのORを更新
    # 更新したbitはbitsに追加
    add_bits = set()
    for bit in bits:
        tmp = bit | key
        if dp[bit] + a < dp[tmp]:
            dp[tmp] = dp[bit] + a
            add_bits.add(tmp)
    bits |= add_bits
    
if dp[(1 << N) - 1] == inf:
    print(-1)
else:
    print(dp[(1 << N) - 1]) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M inf = int(1e10) inf int(1e10) int 1e10 dp = [inf] * (1 << N) dp [inf] * (1 << N) [inf] inf 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 bits = set() bits set() set bits.add(0) bits.add bits add 0 for i in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    # cを状態keyに変換
    key = 0
    for t in c:
        key += 1 << (t - 1)
    # bits内のbitとkeyのORを更新
    # 更新したbitはbitsに追加
    add_bits = set()
    for bit in bits:
        tmp = bit | key
        if dp[bit] + a < dp[tmp]:
            dp[tmp] = dp[bit] + a
            add_bits.add(tmp)
    bits |= add_bits
     i range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split key = 0 key 0 for t in c:
        key += 1 << (t - 1)
    # bits内のbitとkeyのORを更新
    # 更新したbitはbitsに追加
     t c key += 1 << (t - 1) key 1 << (t - 1) 1 t - 1 t 1 add_bits = set() add_bits set() set for bit in bits:
        tmp = bit | key
        if dp[bit] + a < dp[tmp]:
            dp[tmp] = dp[bit] + a
            add_bits.add(tmp)
     bit bits tmp = bit | key tmp bit | key bit key if dp[bit] + a < dp[tmp]:
            dp[tmp] = dp[bit] + a
            add_bits.add(tmp)
     dp[bit] + a < dp[tmp] dp[bit] + a dp[bit] dp bit a dp[tmp] dp tmp dp[tmp] = dp[bit] + a dp[tmp] dp tmp dp[bit] + a dp[bit] dp bit a add_bits.add(tmp) add_bits.add add_bits add tmp bits |= add_bits bits add_bits if dp[(1 << N) - 1] == inf:
    print(-1)
else:
    print(dp[(1 << N) - 1]) dp[(1 << N) - 1] == inf dp[(1 << N) - 1] dp (1 << N) - 1 1 << N 1 N 1 inf print(-1) print -1 print(dp[(1 << N) - 1]) print dp[(1 << N) - 1] dp (1 << N) - 1 1 << N 1 N 1 a, b = map(int, input().split()) map(int, input().split()) a tmp = bit | key bit | key tmp bits = set() set() bits c = list(map(int, input().split())) list(map(int, input().split())) c M = map(int, input().split()) map(int, input().split()) M add_bits = set() set() add_bits bits |= add_bits add_bits bits N, M = map(int, input().split()) map(int, input().split()) N dp = [inf] * (1 << N) [inf] * (1 << N) dp key += 1 << (t - 1) 1 << (t - 1) key key = 0 0 key b = map(int, input().split()) map(int, input().split()) b inf = int(1e10) int(1e10) inf
N, M = map(int, input().split())
inf = int(1e10)
dp = [inf] * (1 << N) #1をNだけシフトする 2**B

#鍵をビットで表す　dp[i]は鍵の状態iにできる最小費用を
dp[0] = 0
bits = set()
bits.add(0)

for i in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    # cを状態keyに変換
    key = 0
    for t in c:
        key += 1 << (t - 1)
    # bits内のbitとkeyのORを更新
    # 更新したbitはbitsに追加
    add_bits = set()
    for bit in bits:
        tmp = bit | key
        if dp[bit] + a < dp[tmp]:
            dp[tmp] = dp[bit] + a
            add_bits.add(tmp)
    bits |= add_bits
    
if dp[(1 << N) - 1] == inf:
    print(-1)
else:
    print(dp[(1 << N) - 1])