ans = 10 ** 7
n, m = map(int, input().split())
dp = [float('inf')] * (2 ** n)
dp[0] = 0
prices = []
for i in range(m):
    a, s = map(int, input().split())
    prices.append(a)
    f = 0
    for k in map(int, input().split()):
        f += 2 ** (k - 1)
    for j in range(2 ** n - 1, -1, -1):
        dp[j | f] = min(dp[j] + a, dp[j | f])
print(-1 if dp[-1] == float('inf') else dp[-1]) ans = 10 ** 7 ans 10 ** 7 10 7 n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m dp = [float('inf')] * (2 ** n) dp [float('inf')] * (2 ** n) [float('inf')] float('inf') float 'inf' 2 ** n 2 n dp[0] = 0 dp[0] dp 0 0 prices = [] prices [] for i in range(m):
    a, s = map(int, input().split())
    prices.append(a)
    f = 0
    for k in map(int, input().split()):
        f += 2 ** (k - 1)
    for j in range(2 ** n - 1, -1, -1):
        dp[j | f] = min(dp[j] + a, dp[j | f]) i range(m) range m a, s = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split s prices.append(a) prices.append prices append a f = 0 f 0 for k in map(int, input().split()):
        f += 2 ** (k - 1)
     k map(int, input().split()) map int input().split() ().split () input split f += 2 ** (k - 1) f 2 ** (k - 1) 2 k - 1 k 1 for j in range(2 ** n - 1, -1, -1):
        dp[j | f] = min(dp[j] + a, dp[j | f]) j range(2 ** n - 1, -1, -1) range 2 ** n - 1 2 ** n 2 n 1 -1 -1 dp[j | f] = min(dp[j] + a, dp[j | f]) dp[j | f] dp j | f j f min(dp[j] + a, dp[j | f]) min dp[j] + a dp[j] dp j a dp[j | f] dp j | f j f print(-1 if dp[-1] == float('inf') else dp[-1]) print -1 if dp[-1] == float('inf') else dp[-1] dp[-1] == float('inf') dp[-1] dp -1 float('inf') float 'inf' -1 dp[-1] dp -1 ans = 10 ** 7 10 ** 7 ans dp = [float('inf')] * (2 ** n) [float('inf')] * (2 ** n) dp f = 0 0 f s = map(int, input().split()) map(int, input().split()) s a, s = map(int, input().split()) map(int, input().split()) a m = map(int, input().split()) map(int, input().split()) m f += 2 ** (k - 1) 2 ** (k - 1) f n, m = map(int, input().split()) map(int, input().split()) n prices = [] [] prices
ans = 10 ** 7
n, m = map(int, input().split())
dp = [float('inf')] * (2 ** n)
dp[0] = 0
prices = []
for i in range(m):
    a, s = map(int, input().split())
    prices.append(a)
    f = 0
    for k in map(int, input().split()):
        f += 2 ** (k - 1)
    for j in range(2 ** n - 1, -1, -1):
        dp[j | f] = min(dp[j] + a, dp[j | f])
print(-1 if dp[-1] == float('inf') else dp[-1])