import sys
input = sys.stdin.readline

N, M = map(int, input().split())
INF = float('inf')
dp = [INF] * (1 << N)
dp[0] = 0
for _ in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for i in c:
        bit += 1 << (i-1)
    for i in range(1 << N):
        dp[i | bit] = min(dp[i | bit], dp[i] + a)
print(dp[-1] if dp[-1] != INF else -1) 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 INF = float('inf') INF float('inf') float 'inf' dp = [INF] * (1 << N) dp [INF] * (1 << N) [INF] INF 1 << N 1 N dp[0] = 0 dp[0] dp 0 0 for _ in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for i in c:
        bit += 1 << (i-1)
    for i in range(1 << N):
        dp[i | bit] = min(dp[i | bit], dp[i] + a) _ 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 bit = 0 bit 0 for i in c:
        bit += 1 << (i-1)
     i c bit += 1 << (i-1) bit 1 << (i-1) 1 i-1 i 1 for i in range(1 << N):
        dp[i | bit] = min(dp[i | bit], dp[i] + a) i range(1 << N) range 1 << N 1 N dp[i | bit] = min(dp[i | bit], dp[i] + a) dp[i | bit] dp i | bit i bit min(dp[i | bit], dp[i] + a) min dp[i | bit] dp i | bit i bit dp[i] + a dp[i] dp i a print(dp[-1] if dp[-1] != INF else -1) print dp[-1] if dp[-1] != INF else -1 dp[-1] != INF dp[-1] dp -1 INF dp[-1] dp -1 -1 N, M = map(int, input().split()) map(int, input().split()) N c = list(map(int, input().split())) list(map(int, input().split())) c bit = 0 0 bit INF = float('inf') float('inf') INF dp = [INF] * (1 << N) [INF] * (1 << N) dp input = sys.stdin.readline sys.stdin.readline input bit += 1 << (i-1) 1 << (i-1) bit a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b M = map(int, input().split()) map(int, input().split()) M
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
INF = float('inf')
dp = [INF] * (1 << N)
dp[0] = 0
for _ in range(M):
    a, b = map(int, input().split())
    c = list(map(int, input().split()))
    bit = 0
    for i in c:
        bit += 1 << (i-1)
    for i in range(1 << N):
        dp[i | bit] = min(dp[i | bit], dp[i] + a)
print(dp[-1] if dp[-1] != INF else -1)
