import sys
input = sys.stdin.readline

n, m = map(int, input().split())
dp = [float('inf')] * (2 ** n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().split())
    c = sum(1 << (i - 1) for i in map(int, input().split()))
    for j in range(2 ** n):
        if dp[c | j] > dp[j] + a:
            dp[c | j] = dp[j] + a

if dp[-1] == float('inf'):
    ans = -1
else:
    ans = dp[-1]
print(ans) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline 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 for i in range(m):
    a, b = map(int, input().split())
    c = sum(1 << (i - 1) for i in map(int, input().split()))
    for j in range(2 ** n):
        if dp[c | j] > dp[j] + a:
            dp[c | j] = dp[j] + a i range(m) range m a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b c = sum(1 << (i - 1) for i in map(int, input().split())) c sum(1 << (i - 1) for i in map(int, input().split())) sum 1 << (i - 1) 1 i - 1 i 1 for j in range(2 ** n):
        if dp[c | j] > dp[j] + a:
            dp[c | j] = dp[j] + a j range(2 ** n) range 2 ** n 2 n if dp[c | j] > dp[j] + a:
            dp[c | j] = dp[j] + a dp[c | j] > dp[j] + a dp[c | j] dp c | j c j dp[j] + a dp[j] dp j a dp[c | j] = dp[j] + a dp[c | j] dp c | j c j dp[j] + a dp[j] dp j a if dp[-1] == float('inf'):
    ans = -1
else:
    ans = dp[-1] dp[-1] == float('inf') dp[-1] dp -1 float('inf') float 'inf' ans = -1 ans -1 ans = dp[-1] ans dp[-1] dp -1 print(ans) print ans ans = -1 -1 ans ans = dp[-1] dp[-1] ans m = map(int, input().split()) map(int, input().split()) m c = sum(1 << (i - 1) for i in map(int, input().split())) sum(1 << (i - 1) for i in map(int, input().split())) c a, b = map(int, input().split()) map(int, input().split()) a n, m = map(int, input().split()) map(int, input().split()) n b = map(int, input().split()) map(int, input().split()) b dp = [float('inf')] * (2 ** n) [float('inf')] * (2 ** n) dp input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
dp = [float('inf')] * (2 ** n)
dp[0] = 0
for i in range(m):
    a, b = map(int, input().split())
    c = sum(1 << (i - 1) for i in map(int, input().split()))
    for j in range(2 ** n):
        if dp[c | j] > dp[j] + a:
            dp[c | j] = dp[j] + a

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