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]*(m+1) for _ in range(n_bit)]
dp[0][0] = 0

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

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

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

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