N, M = map(int, input().split())

INF = float("inf")
dp = [INF for i in range(2**N)]
dp[0] = 0
for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    key = 0
    for c in C:
        key += 2**(c-1)
    for j in range(len(dp)-1, -1, -1):
        if dp[j] == INF:
            continue
        if dp[j | key] > dp[j] + a:
            dp[j | key] = dp[j] + a
            
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1]) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M INF = float("inf") INF float("inf") float "inf" INF for i in range(2**N) for i in range(2**N) i range(2**N) range 2**N 2 N for i in range(2**N) INF dp = [INF for i in range(2**N)] dp [INF for i in range(2**N)] dp[0] = 0 dp[0] dp 0 0 for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    key = 0
    for c in C:
        key += 2**(c-1)
    for j in range(len(dp)-1, -1, -1):
        if dp[j] == INF:
            continue
        if dp[j | key] > dp[j] + a:
            dp[j | key] = 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 = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split key = 0 key 0 for c in C:
        key += 2**(c-1)
     c C key += 2**(c-1) key 2**(c-1) 2 c-1 c 1 for j in range(len(dp)-1, -1, -1):
        if dp[j] == INF:
            continue
        if dp[j | key] > dp[j] + a:
            dp[j | key] = dp[j] + a
             j range(len(dp)-1, -1, -1) range len(dp)-1 len(dp) len dp 1 -1 -1 if dp[j] == INF:
            continue
         dp[j] == INF dp[j] dp j INF continue if dp[j | key] > dp[j] + a:
            dp[j | key] = dp[j] + a
             dp[j | key] > dp[j] + a dp[j | key] dp j | key j key dp[j] + a dp[j] dp j a dp[j | key] = dp[j] + a dp[j | key] dp j | key j key dp[j] + a dp[j] dp j a if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1]) dp[-1] == INF dp[-1] dp -1 INF print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 N, M = map(int, input().split()) map(int, input().split()) N a, b = map(int, input().split()) map(int, input().split()) a M = map(int, input().split()) map(int, input().split()) M key = 0 0 key dp = [INF for i in range(2**N)] [INF for i in range(2**N)] dp key += 2**(c-1) 2**(c-1) key INF = float("inf") float("inf") INF b = map(int, input().split()) map(int, input().split()) b C = list(map(int, input().split())) list(map(int, input().split())) C
N, M = map(int, input().split())

INF = float("inf")
dp = [INF for i in range(2**N)]
dp[0] = 0
for i in range(M):
    a, b = map(int, input().split())
    C = list(map(int, input().split()))
    key = 0
    for c in C:
        key += 2**(c-1)
    for j in range(len(dp)-1, -1, -1):
        if dp[j] == INF:
            continue
        if dp[j | key] > dp[j] + a:
            dp[j | key] = dp[j] + a
            
if dp[-1] == INF:
    print(-1)
else:
    print(dp[-1])
