n, m = map(int, input().split())
key = []
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    v = 0
    for i in range(b):
        v += 1 << (c[i] - 1)
    key.append([a, v])

dp = [[float('inf')] * (1<<n) for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    money, value = key[i]
    for j in range(1<<n):
        dp[i+1][j|value] = min(dp[i+1][j|value], dp[i][j] + money)
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

print(dp[-1][-1] if dp[-1][-1] != float('inf') else -1) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m key = [] key [] for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    v = 0
    for i in range(b):
        v += 1 << (c[i] - 1)
    key.append([a, v]) _ range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split v = 0 v 0 for i in range(b):
        v += 1 << (c[i] - 1)
     i range(b) range b v += 1 << (c[i] - 1) v 1 << (c[i] - 1) 1 c[i] - 1 c[i] c i 1 key.append([a, v]) key.append key append [a, v] a v [float('inf')] * (1<<n) for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [float('inf')] * (1<<n) [float('inf')] float('inf') float 'inf' 1<<n 1 n dp = [[float('inf')] * (1<<n) for _ in range(m+1)] dp [[float('inf')] * (1<<n) for _ in range(m+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(m):
    money, value = key[i]
    for j in range(1<<n):
        dp[i+1][j|value] = min(dp[i+1][j|value], dp[i][j] + money)
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]) i range(m) range m money, value = key[i] money key[i] key i value for j in range(1<<n):
        dp[i+1][j|value] = min(dp[i+1][j|value], dp[i][j] + money)
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]) j range(1<<n) range 1<<n 1 n dp[i+1][j|value] = min(dp[i+1][j|value], dp[i][j] + money) dp[i+1][j|value] [i+1] dp i+1 i 1 j|value j value min(dp[i+1][j|value], dp[i][j] + money) min dp[i+1][j|value] [i+1] dp i+1 i 1 j|value j value dp[i][j] + money dp[i][j] [i] dp i j money dp[i+1][j] = min(dp[i+1][j], dp[i][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i+1][j], dp[i][j]) min dp[i+1][j] [i+1] dp i+1 i 1 j dp[i][j] [i] dp i j print(dp[-1][-1] if dp[-1][-1] != float('inf') else -1) print dp[-1][-1] if dp[-1][-1] != float('inf') else -1 dp[-1][-1] != float('inf') dp[-1][-1] [-1] dp -1 -1 float('inf') float 'inf' dp[-1][-1] [-1] dp -1 -1 -1 a, b = map(int, input().split()) map(int, input().split()) a key = [] [] key b = map(int, input().split()) map(int, input().split()) b v = 0 0 v dp = [[float('inf')] * (1<<n) for _ in range(m+1)] [[float('inf')] * (1<<n) for _ in range(m+1)] dp m = map(int, input().split()) map(int, input().split()) m v += 1 << (c[i] - 1) 1 << (c[i] - 1) v money, value = key[i] key[i] money c = list(map(int, input().split())) list(map(int, input().split())) c n, m = map(int, input().split()) map(int, input().split()) n value = key[i] key[i] value
n, m = map(int, input().split())
key = []
for _ in range(m):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    v = 0
    for i in range(b):
        v += 1 << (c[i] - 1)
    key.append([a, v])

dp = [[float('inf')] * (1<<n) for _ in range(m+1)]
dp[0][0] = 0
for i in range(m):
    money, value = key[i]
    for j in range(1<<n):
        dp[i+1][j|value] = min(dp[i+1][j|value], dp[i][j] + money)
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

print(dp[-1][-1] if dp[-1][-1] != float('inf') else -1)