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

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

dp = [10**18] * (1 << N)
dp[0] = 0
for state in range(1 << N):
    for a, k in K:
        dp[state | k] = min(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(int, input().split()):
        k |= (1 << (i - 1))
    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(int, input().split()):
        k |= (1 << (i - 1))
     i map(int, input().split()) map int input().split() ().split () input split k |= (1 << (i - 1)) k 1 << (i - 1) 1 i - 1 i 1 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:
        dp[state | k] = min(dp[state | k], dp[state] + a) state range(1 << N) range 1 << N 1 N for a, k in K:
        dp[state | k] = min(dp[state | k], dp[state] + a) a k K dp[state | k] = min(dp[state | k], dp[state] + a) dp[state | k] dp state | k state k min(dp[state | k], dp[state] + a) min 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 k |= (1 << (i - 1)) 1 << (i - 1) k 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 dp = [10**18] * (1 << N) [10**18] * (1 << N) dp M = map(int, input().split()) map(int, input().split()) M _ = map(int, input().split()) map(int, input().split()) _ N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())
K = []

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

dp = [10**18] * (1 << N)
dp[0] = 0
for state in range(1 << N):
    for a, k in K:
        dp[state | k] = min(dp[state | k], dp[state] + a)

ans = dp[(1 << N) - 1]
print(ans if ans < 10**18 else -1)
