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

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

for i in range(m):
    for j in range(n_bit):
        dp[j | can_open[i]] = min(dp[j | can_open[i]], dp[j]+cost[i])

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

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

for i in range(m):
    for j in range(n_bit):
        dp[j | can_open[i]] = min(dp[j | can_open[i]], dp[j]+cost[i])

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