n, m = map(int, input().split())
can_open = []
cost = []
for _ in range(m):
    a, b = map(int, input().split())
    cost.append(a)
    can_open.append(sum(1 << (c-1) for c in map(int, input().split())))

n_bit = 1 << n
INF = 10**18
dp = [INF]*n_bit
dp[0] = 0

for x, y in zip(can_open, cost):
    for j in range(n_bit):
        m = j | x
        z = dp[j]+y
        if dp[m] > z:
            dp[m] = z

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 can_open = [] can_open [] cost = [] cost [] for _ in range(m):
    a, b = map(int, input().split())
    cost.append(a)
    can_open.append(sum(1 << (c-1) for c in map(int, input().split()))) _ range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b cost.append(a) cost.append cost append a can_open.append(sum(1 << (c-1) for c in map(int, input().split()))) can_open.append can_open append sum(1 << (c-1) for c in map(int, input().split())) sum 1 << (c-1) 1 c-1 c 1 n_bit = 1 << n n_bit 1 << n 1 n INF = 10**18 INF 10**18 10 18 dp = [INF]*n_bit dp [INF]*n_bit [INF] INF n_bit dp[0] = 0 dp[0] dp 0 0 for x, y in zip(can_open, cost):
    for j in range(n_bit):
        m = j | x
        z = dp[j]+y
        if dp[m] > z:
            dp[m] = z x y zip(can_open, cost) zip can_open cost for j in range(n_bit):
        m = j | x
        z = dp[j]+y
        if dp[m] > z:
            dp[m] = z j range(n_bit) range n_bit m = j | x m j | x j x z = dp[j]+y z dp[j]+y dp[j] dp j y if dp[m] > z:
            dp[m] = z dp[m] > z dp[m] dp m z dp[m] = z dp[m] dp m z 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 INF = 10**18 10**18 INF cost = [] [] cost z = dp[j]+y dp[j]+y z can_open = [] [] can_open m = map(int, input().split()) map(int, input().split()) m dp = [INF]*n_bit [INF]*n_bit dp m = j | x j | x m n, m = map(int, input().split()) map(int, input().split()) n a, b = map(int, input().split()) map(int, input().split()) a n_bit = 1 << n 1 << n n_bit b = map(int, input().split()) map(int, input().split()) b
n, m = map(int, input().split())
can_open = []
cost = []
for _ in range(m):
    a, b = map(int, input().split())
    cost.append(a)
    can_open.append(sum(1 << (c-1) for c in map(int, input().split())))

n_bit = 1 << n
INF = 10**18
dp = [INF]*n_bit
dp[0] = 0

for x, y in zip(can_open, cost):
    for j in range(n_bit):
        m = j | x
        z = dp[j]+y
        if dp[m] > z:
            dp[m] = z

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