n,m = map(int,input().split())
dp = [[10**9]*(2**n+5) for _ 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()))
    res = 0
    for x in c:
        res|=1<<(x-1)
    for j in range(2**n):
        ni = i+1
        nj = j|res
        dp[ni][j] = min(dp[ni][j],dp[i][j])
        dp[ni][nj] = min(dp[ni][nj],dp[i][j]+a)
ans = dp[m][2**n-1]
if ans == 10**9:ans = -1
print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m [10**9]*(2**n+5) for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) [10**9]*(2**n+5) [10**9] 10**9 10 9 2**n+5 2**n 2 n 5 dp = [[10**9]*(2**n+5) for _ in range(m+1)] dp [[10**9]*(2**n+5) for _ 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()))
    res = 0
    for x in c:
        res|=1<<(x-1)
    for j in range(2**n):
        ni = i+1
        nj = j|res
        dp[ni][j] = min(dp[ni][j],dp[i][j])
        dp[ni][nj] = min(dp[ni][nj],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 res = 0 res 0 for x in c:
        res|=1<<(x-1)
     x c res|=1<<(x-1) res 1<<(x-1) 1 x-1 x 1 for j in range(2**n):
        ni = i+1
        nj = j|res
        dp[ni][j] = min(dp[ni][j],dp[i][j])
        dp[ni][nj] = min(dp[ni][nj],dp[i][j]+a) j range(2**n) range 2**n 2 n ni = i+1 ni i+1 i 1 nj = j|res nj j|res j res dp[ni][j] = min(dp[ni][j],dp[i][j]) dp[ni][j] [ni] dp ni j min(dp[ni][j],dp[i][j]) min dp[ni][j] [ni] dp ni j dp[i][j] [i] dp i j dp[ni][nj] = min(dp[ni][nj],dp[i][j]+a) dp[ni][nj] [ni] dp ni nj min(dp[ni][nj],dp[i][j]+a) min dp[ni][nj] [ni] dp ni nj dp[i][j]+a dp[i][j] [i] dp i j a ans = dp[m][2**n-1] ans dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 if ans == 10**9:ans = -1 ans == 10**9 ans 10**9 10 9 print(ans) print ans ans = dp[m][2**n-1] dp[m][2**n-1] ans ni = i+1 i+1 ni res = 0 0 res 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 res|=1<<(x-1) 1<<(x-1) res c = list(map(int,input().split())) list(map(int,input().split())) c nj = j|res j|res nj m = map(int,input().split()) map(int,input().split()) m dp = [[10**9]*(2**n+5) for _ in range(m+1)] [[10**9]*(2**n+5) for _ in range(m+1)] dp
n,m = map(int,input().split())
dp = [[10**9]*(2**n+5) for _ 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()))
    res = 0
    for x in c:
        res|=1<<(x-1)
    for j in range(2**n):
        ni = i+1
        nj = j|res
        dp[ni][j] = min(dp[ni][j],dp[i][j])
        dp[ni][nj] = min(dp[ni][nj],dp[i][j]+a)
ans = dp[m][2**n-1]
if ans == 10**9:ans = -1
print(ans)