N, M = map(int, input().split())
key = [[] for _ in range(M)]
for i in range(M):
    a, _ = map(int, input().split())
    # 空けることができる宝箱をbitで表す
    c = 0
    for v in list(map(int, input().split())):
        c += pow(2, v-1)
    key[i] = [a, c]

status_count = pow(2, N)
INF = 10 ** 30
# keyの各要素の先頭が値段になってる
dp = [INF] * (status_count)
dp[0] = 0
for a, c in key:
    # 今対象の鍵を購入したときの最小値を求める
    for i in range(status_count):
        dp[i | c] = min(dp[i | c], dp[i] + a)

print(dp[-1] if dp[-1] < INF else -1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M [] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [] key = [[] for _ in range(M)] key [[] for _ in range(M)] for i in range(M):
    a, _ = map(int, input().split())
    # 空けることができる宝箱をbitで表す
    c = 0
    for v in list(map(int, input().split())):
        c += pow(2, v-1)
    key[i] = [a, c] i 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 v in list(map(int, input().split())):
        c += pow(2, v-1)
     v list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c += pow(2, v-1) c pow(2, v-1) pow 2 v-1 v 1 key[i] = [a, c] key[i] key i [a, c] a c status_count = pow(2, N) status_count pow(2, N) pow 2 N INF = 10 ** 30 INF 10 ** 30 10 30 dp = [INF] * (status_count) dp [INF] * (status_count) [INF] INF status_count dp[0] = 0 dp[0] dp 0 0 for a, c in key:
    # 今対象の鍵を購入したときの最小値を求める
    for i in range(status_count):
        dp[i | c] = min(dp[i | c], dp[i] + a) a c key for i in range(status_count):
        dp[i | c] = min(dp[i | c], dp[i] + a) i range(status_count) range status_count dp[i | c] = min(dp[i | c], dp[i] + a) dp[i | c] dp i | c i c min(dp[i | c], dp[i] + a) min dp[i | c] dp i | c i c dp[i] + a dp[i] dp i a 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 status_count = pow(2, N) pow(2, N) status_count c += pow(2, v-1) pow(2, v-1) c dp = [INF] * (status_count) [INF] * (status_count) dp M = map(int, input().split()) map(int, input().split()) M INF = 10 ** 30 10 ** 30 INF N, M = map(int, input().split()) map(int, input().split()) N c = 0 0 c a, _ = map(int, input().split()) map(int, input().split()) a _ = map(int, input().split()) map(int, input().split()) _ key = [[] for _ in range(M)] [[] for _ in range(M)] key
N, M = map(int, input().split())
key = [[] for _ in range(M)]
for i in range(M):
    a, _ = map(int, input().split())
    # 空けることができる宝箱をbitで表す
    c = 0
    for v in list(map(int, input().split())):
        c += pow(2, v-1)
    key[i] = [a, c]

status_count = pow(2, N)
INF = 10 ** 30
# keyの各要素の先頭が値段になってる
dp = [INF] * (status_count)
dp[0] = 0
for a, c in key:
    # 今対象の鍵を購入したときの最小値を求める
    for i in range(status_count):
        dp[i | c] = min(dp[i | c], dp[i] + a)

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