N, M = map(int,input().split())
key = [0] * M
cost = [0] * M
for i in range(M):
    a, b = map(int,input().split())
    cost[i] = a
    key_id = list(map(int,input().split()))
    for j in range(b):
        key[i] |= (1 << (key_id[j] - 1))
dp = [[float("inf")] * (1<<N)] * (M + 1)
dp[0][0] = 0
for i in range(M):
    for j in range(1<<N):
        if dp[i + 1][j | key[i]] > dp[i][j] + cost[i]:
            dp[i + 1][j | key[i]] = dp[i][j] + cost[i]
        if dp[i + 1][j] > dp[i][j]:
            dp[i + 1][j] = dp[i][j]
if dp[-1][-1] == float("inf"):
    print(-1)
else:
    print(dp[-1][-1]) N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M key = [0] * M key [0] * M [0] 0 M cost = [0] * M cost [0] * M [0] 0 M for i in range(M):
    a, b = map(int,input().split())
    cost[i] = a
    key_id = list(map(int,input().split()))
    for j in range(b):
        key[i] |= (1 << (key_id[j] - 1)) i range(M) range M a, b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b cost[i] = a cost[i] cost i a key_id = list(map(int,input().split())) key_id list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in range(b):
        key[i] |= (1 << (key_id[j] - 1)) j range(b) range b key[i] |= (1 << (key_id[j] - 1)) key[i] key i 1 << (key_id[j] - 1) 1 key_id[j] - 1 key_id[j] key_id j 1 dp = [[float("inf")] * (1<<N)] * (M + 1) dp [[float("inf")] * (1<<N)] * (M + 1) [[float("inf")] * (1<<N)] [float("inf")] * (1<<N) [float("inf")] float("inf") float "inf" 1<<N 1 N M + 1 M 1 dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    for j in range(1<<N):
        if dp[i + 1][j | key[i]] > dp[i][j] + cost[i]:
            dp[i + 1][j | key[i]] = dp[i][j] + cost[i]
        if dp[i + 1][j] > dp[i][j]:
            dp[i + 1][j] = dp[i][j] i range(M) range M for j in range(1<<N):
        if dp[i + 1][j | key[i]] > dp[i][j] + cost[i]:
            dp[i + 1][j | key[i]] = dp[i][j] + cost[i]
        if dp[i + 1][j] > dp[i][j]:
            dp[i + 1][j] = dp[i][j] j range(1<<N) range 1<<N 1 N if dp[i + 1][j | key[i]] > dp[i][j] + cost[i]:
            dp[i + 1][j | key[i]] = dp[i][j] + cost[i]
         dp[i + 1][j | key[i]] > dp[i][j] + cost[i] dp[i + 1][j | key[i]] [i + 1] dp i + 1 i 1 j | key[i] j key[i] key i dp[i][j] + cost[i] dp[i][j] [i] dp i j cost[i] cost i dp[i + 1][j | key[i]] = dp[i][j] + cost[i] dp[i + 1][j | key[i]] [i + 1] dp i + 1 i 1 j | key[i] j key[i] key i dp[i][j] + cost[i] dp[i][j] [i] dp i j cost[i] cost i if dp[i + 1][j] > dp[i][j]:
            dp[i + 1][j] = dp[i][j] dp[i + 1][j] > dp[i][j] dp[i + 1][j] [i + 1] dp i + 1 i 1 j dp[i][j] [i] dp i j dp[i + 1][j] = dp[i][j] dp[i + 1][j] [i + 1] dp i + 1 i 1 j dp[i][j] [i] dp i j if dp[-1][-1] == float("inf"):
    print(-1)
else:
    print(dp[-1][-1]) dp[-1][-1] == float("inf") dp[-1][-1] [-1] dp -1 -1 float("inf") float "inf" print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 b = map(int,input().split()) map(int,input().split()) b a, b = map(int,input().split()) map(int,input().split()) a cost = [0] * M [0] * M cost dp = [[float("inf")] * (1<<N)] * (M + 1) [[float("inf")] * (1<<N)] * (M + 1) dp key = [0] * M [0] * M key N, M = map(int,input().split()) map(int,input().split()) N key_id = list(map(int,input().split())) list(map(int,input().split())) key_id M = map(int,input().split()) map(int,input().split()) M
N, M = map(int,input().split())
key = [0] * M
cost = [0] * M
for i in range(M):
    a, b = map(int,input().split())
    cost[i] = a
    key_id = list(map(int,input().split()))
    for j in range(b):
        key[i] |= (1 << (key_id[j] - 1))
dp = [[float("inf")] * (1<<N)] * (M + 1)
dp[0][0] = 0
for i in range(M):
    for j in range(1<<N):
        if dp[i + 1][j | key[i]] > dp[i][j] + cost[i]:
            dp[i + 1][j | key[i]] = dp[i][j] + cost[i]
        if dp[i + 1][j] > dp[i][j]:
            dp[i + 1][j] = dp[i][j]
if dp[-1][-1] == float("inf"):
    print(-1)
else:
    print(dp[-1][-1])