N, M = map(int, input().split())
K = []

for _ in range(M):
    a, _ = map(int, input().split())
    k = 0
    for i in map(lambda a: int(a) - 1, input().split()):
        k |= (1 << i)
    K.append((a, k))

dp = [10**18] * (1 << N)
dp[0] = 0
for state in range(1 << N):
    for a, k in K:
        if dp[state | k] > dp[state] + a:
            dp[state | k] = dp[state] + a
ans = dp[(1 << N) - 1]
print(ans if ans < 10**18 else -1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M K = [] K [] for _ in range(M):
    a, _ = map(int, input().split())
    k = 0
    for i in map(lambda a: int(a) - 1, input().split()):
        k |= (1 << i)
    K.append((a, k)) _ range(M) range M a, _ = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split _ k = 0 k 0 for i in map(lambda a: int(a) - 1, input().split()):
        k |= (1 << i)
     i map(lambda a: int(a) - 1, input().split()) map lambda a: int(a) - 1 int(a) - 1 int(a) int a 1 a input().split() ().split () input split k |= (1 << i) k 1 << i 1 i K.append((a, k)) K.append K append (a, k) a k dp = [10**18] * (1 << N) dp [10**18] * (1 << N) [10**18] 10**18 10 18 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for state in range(1 << N):
    for a, k in K:
        if dp[state | k] > dp[state] + a:
            dp[state | k] = dp[state] + a state range(1 << N) range 1 << N 1 N for a, k in K:
        if dp[state | k] > dp[state] + a:
            dp[state | k] = dp[state] + a a k K if dp[state | k] > dp[state] + a:
            dp[state | k] = dp[state] + a dp[state | k] > dp[state] + a dp[state | k] dp state | k state k dp[state] + a dp[state] dp state a dp[state | k] = dp[state] + a dp[state | k] dp state | k state k dp[state] + a dp[state] dp state a ans = dp[(1 << N) - 1] ans dp[(1 << N) - 1] dp (1 << N) - 1 1 << N 1 N 1 print(ans if ans < 10**18 else -1) print ans if ans < 10**18 else -1 ans < 10**18 ans 10**18 10 18 ans -1 dp = [10**18] * (1 << N) [10**18] * (1 << N) dp M = map(int, input().split()) map(int, input().split()) M N, M = map(int, input().split()) map(int, input().split()) N _ = map(int, input().split()) map(int, input().split()) _ K = [] [] K ans = dp[(1 << N) - 1] dp[(1 << N) - 1] ans k = 0 0 k a, _ = map(int, input().split()) map(int, input().split()) a k |= (1 << i) 1 << i k
N, M = map(int, input().split())
K = []

for _ in range(M):
    a, _ = map(int, input().split())
    k = 0
    for i in map(lambda a: int(a) - 1, input().split()):
        k |= (1 << i)
    K.append((a, k))

dp = [10**18] * (1 << N)
dp[0] = 0
for state in range(1 << N):
    for a, k in K:
        if dp[state | k] > dp[state] + a:
            dp[state | k] = dp[state] + a
ans = dp[(1 << N) - 1]
print(ans if ans < 10**18 else -1)
