INF = 10 ** 9
N, M = map(int,input().split())
dp = [[INF for i in range(1 << N)] for j in range(M+1)]
dp[0][0] = 0
for i in range(M):
    a, b = map(int,input().split())
    c = list(map(int,input().split()))
    k = 0
    for l in c:
        k += 1 << (l - 1)
    for j in range(1 << N):
        if dp[i][j] != INF:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i+1][j | k] = min(dp[i+1][j | k], dp[i][j] + a)

if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1]) INF = 10 ** 9 INF 10 ** 9 10 9 N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M [INF for i in range(1 << N)] for j in range(M+1) for j in range(M+1) j range(M+1) range M+1 M 1 for j in range(M+1) [INF for i in range(1 << N)] dp = [[INF for i in range(1 << N)] for j in range(M+1)] dp [[INF for i in range(1 << N)] for j in range(M+1)] dp[0][0] = 0 dp[0][0] [0] dp 0 0 0 for i in range(M):
    a, b = map(int,input().split())
    c = list(map(int,input().split()))
    k = 0
    for l in c:
        k += 1 << (l - 1)
    for j in range(1 << N):
        if dp[i][j] != INF:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i+1][j | k] = min(dp[i+1][j | k], dp[i][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 k = 0 k 0 for l in c:
        k += 1 << (l - 1)
     l c k += 1 << (l - 1) k 1 << (l - 1) 1 l - 1 l 1 for j in range(1 << N):
        if dp[i][j] != INF:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i+1][j | k] = min(dp[i+1][j | k], dp[i][j] + a) j range(1 << N) range 1 << N 1 N if dp[i][j] != INF:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i+1][j | k] = min(dp[i+1][j | k], dp[i][j] + a) dp[i][j] != INF dp[i][j] [i] dp i j INF dp[i+1][j] = min(dp[i][j], dp[i+1][j]) dp[i+1][j] [i+1] dp i+1 i 1 j min(dp[i][j], dp[i+1][j]) min dp[i][j] [i] dp i j dp[i+1][j] [i+1] dp i+1 i 1 j dp[i+1][j | k] = min(dp[i+1][j | k], dp[i][j] + a) dp[i+1][j | k] [i+1] dp i+1 i 1 j | k j k min(dp[i+1][j | k], dp[i][j] + a) min dp[i+1][j | k] [i+1] dp i+1 i 1 j | k j k dp[i][j] + a dp[i][j] [i] dp i j a if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1]) dp[-1][-1] == INF dp[-1][-1] [-1] dp -1 -1 INF print(-1) print -1 print(dp[-1][-1]) print dp[-1][-1] [-1] dp -1 -1 INF = 10 ** 9 10 ** 9 INF M = map(int,input().split()) map(int,input().split()) M k += 1 << (l - 1) 1 << (l - 1) k dp = [[INF for i in range(1 << N)] for j in range(M+1)] [[INF for i in range(1 << N)] for j in range(M+1)] dp a, b = map(int,input().split()) map(int,input().split()) a b = map(int,input().split()) map(int,input().split()) b N, M = map(int,input().split()) map(int,input().split()) N c = list(map(int,input().split())) list(map(int,input().split())) c k = 0 0 k
INF = 10 ** 9
N, M = map(int,input().split())
dp = [[INF for i in range(1 << N)] for j in range(M+1)]
dp[0][0] = 0
for i in range(M):
    a, b = map(int,input().split())
    c = list(map(int,input().split()))
    k = 0
    for l in c:
        k += 1 << (l - 1)
    for j in range(1 << N):
        if dp[i][j] != INF:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i+1][j | k] = min(dp[i+1][j | k], dp[i][j] + a)

if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1])