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

dp = [10**10 for B in range(1 << N)]
dp[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[B | C] = min(dp[B | C], dp[B]+a)

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

dp = [10**10 for B in range(1 << N)]
dp[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[B | C] = min(dp[B | C], dp[B]+a)

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