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

dp = [[10**10 for B in range(1 << N)] for i in range(M+1)]
dp[0][0] = 0

for i in range(M):
    a, b = map(int, input().split())
    c = [int(j) for j in input().split()]
    C = sum([1 << (x-1) for x in c])

    for B in range(1 << N):
        dp[i+1][B] = min(dp[i][B], dp[i+1][B])
        dp[i+1][B | C] = min(dp[i+1][B | C], dp[i][B]+a)

if dp[M][(1 << N)-1] == 10**10:
    print(-1)
else:
    print(dp[M][(1 << N)-1]) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M [10**10 for B in range(1 << N)] for i in range(M+1) for i in range(M+1) i range(M+1) range M+1 M 1 for i in range(M+1) [10**10 for B in range(1 << N)] dp = [[10**10 for B in range(1 << N)] for i in range(M+1)] dp [[10**10 for B in range(1 << N)] for i 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 = [int(j) for j in input().split()]
    C = sum([1 << (x-1) for x in c])

    for B in range(1 << N):
        dp[i+1][B] = min(dp[i][B], dp[i+1][B])
        dp[i+1][B | C] = min(dp[i+1][B | C], dp[i][B]+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 int(j) for j in input().split() for j in input().split() j input().split() ().split () input split for j in input().split() int(j) int j c = [int(j) for j in input().split()] c [int(j) for j in input().split()] 1 << (x-1) for x in c for x in c x c for x in c 1 << (x-1) 1 x-1 x 1 C = sum([1 << (x-1) for x in c]) C sum([1 << (x-1) for x in c]) sum [1 << (x-1) for x in c] for B in range(1 << N):
        dp[i+1][B] = min(dp[i][B], dp[i+1][B])
        dp[i+1][B | C] = min(dp[i+1][B | C], dp[i][B]+a) B range(1 << N) range 1 << N 1 N dp[i+1][B] = min(dp[i][B], dp[i+1][B]) dp[i+1][B] [i+1] dp i+1 i 1 B min(dp[i][B], dp[i+1][B]) min dp[i][B] [i] dp i B dp[i+1][B] [i+1] dp i+1 i 1 B dp[i+1][B | C] = min(dp[i+1][B | C], dp[i][B]+a) dp[i+1][B | C] [i+1] dp i+1 i 1 B | C B C min(dp[i+1][B | C], dp[i][B]+a) min dp[i+1][B | C] [i+1] dp i+1 i 1 B | C B C dp[i][B]+a dp[i][B] [i] dp i B a if dp[M][(1 << N)-1] == 10**10:
    print(-1)
else:
    print(dp[M][(1 << N)-1]) dp[M][(1 << N)-1] == 10**10 dp[M][(1 << N)-1] [M] dp M (1 << N)-1 1 << N 1 N 1 10**10 10 10 print(-1) print -1 print(dp[M][(1 << N)-1]) print dp[M][(1 << N)-1] [M] dp M (1 << N)-1 1 << N 1 N 1 a, b = map(int, input().split()) map(int, input().split()) a M = map(int, input().split()) map(int, input().split()) M b = map(int, input().split()) map(int, input().split()) b N, M = map(int, input().split()) map(int, input().split()) N c = [int(j) for j in input().split()] [int(j) for j in input().split()] c dp = [[10**10 for B in range(1 << N)] for i in range(M+1)] [[10**10 for B in range(1 << N)] for i in range(M+1)] dp C = sum([1 << (x-1) for x in c]) sum([1 << (x-1) for x in c]) C
N, M = map(int, input().split())

dp = [[10**10 for B in range(1 << N)] for i in range(M+1)]
dp[0][0] = 0

for i in range(M):
    a, b = map(int, input().split())
    c = [int(j) for j in input().split()]
    C = sum([1 << (x-1) for x in c])

    for B in range(1 << N):
        dp[i+1][B] = min(dp[i][B], dp[i+1][B])
        dp[i+1][B | C] = min(dp[i+1][B | C], dp[i][B]+a)

if dp[M][(1 << N)-1] == 10**10:
    print(-1)
else:
    print(dp[M][(1 << N)-1])
