N,M = map(int,input().split())
AB, C = [], []
for _ in range(M):
    AB.append(tuple(int(i) for i in input().split()))
    C.append(sum(1<<(int(i)-1) for i in input().split()))

INF = 10**18

# dp[i]: 状態がbin(i)のときの費用の最小値
# bin(i)のj桁が1: j番目の宝箱を開けられる
dp = [INF] * (1<<N)

# 初期条件(全ての宝箱を開けられない)
dp[0] = 0

for i in range(1<<N):
    for (a, _), c in zip(AB,C):
        # 状態iで状態cにする鍵を買ったときの状態
        state = i | c
        dp[state] = min(dp[state], dp[i] + a)

if dp[-1] == INF:
    ans = -1
else:
    ans = dp[-1]
print(ans) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M AB, C = [], [] AB [] C [] for _ in range(M):
    AB.append(tuple(int(i) for i in input().split()))
    C.append(sum(1<<(int(i)-1) for i in input().split())) _ range(M) range M AB.append(tuple(int(i) for i in input().split())) AB.append AB append tuple(int(i) for i in input().split()) tuple int(i) int i C.append(sum(1<<(int(i)-1) for i in input().split())) C.append C append sum(1<<(int(i)-1) for i in input().split()) sum 1<<(int(i)-1) 1 int(i)-1 int(i) int i 1 INF = 10**18 INF 10**18 10 18 dp = [INF] * (1<<N) dp [INF] * (1<<N) [INF] INF 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for i in range(1<<N):
    for (a, _), c in zip(AB,C):
        # 状態iで状態cにする鍵を買ったときの状態
        state = i | c
        dp[state] = min(dp[state], dp[i] + a) i range(1<<N) range 1<<N 1 N for (a, _), c in zip(AB,C):
        # 状態iで状態cにする鍵を買ったときの状態
        state = i | c
        dp[state] = min(dp[state], dp[i] + a) (a, _) a _ c zip(AB,C) zip AB C state = i | c state i | c i c dp[state] = min(dp[state], dp[i] + a) dp[state] dp state min(dp[state], dp[i] + a) min dp[state] dp state dp[i] + a dp[i] dp i a if dp[-1] == INF:
    ans = -1
else:
    ans = dp[-1] dp[-1] == INF dp[-1] dp -1 INF ans = -1 ans -1 ans = dp[-1] ans dp[-1] dp -1 print(ans) print ans ans = dp[-1] dp[-1] ans N,M = map(int,input().split()) map(int,input().split()) N C = [], [] [] C state = i | c i | c state ans = -1 -1 ans INF = 10**18 10**18 INF dp = [INF] * (1<<N) [INF] * (1<<N) dp M = map(int,input().split()) map(int,input().split()) M AB, C = [], [] [] AB
N,M = map(int,input().split())
AB, C = [], []
for _ in range(M):
    AB.append(tuple(int(i) for i in input().split()))
    C.append(sum(1<<(int(i)-1) for i in input().split()))

INF = 10**18

# dp[i]: 状態がbin(i)のときの費用の最小値
# bin(i)のj桁が1: j番目の宝箱を開けられる
dp = [INF] * (1<<N)

# 初期条件(全ての宝箱を開けられない)
dp[0] = 0

for i in range(1<<N):
    for (a, _), c in zip(AB,C):
        # 状態iで状態cにする鍵を買ったときの状態
        state = i | c
        dp[state] = min(dp[state], dp[i] + a)

if dp[-1] == INF:
    ans = -1
else:
    ans = dp[-1]
print(ans)