n, m = map(int, input().split())
a = [None]*m
c = [0]*m
for i in range(m):
    a[i], b = map(int, input().split())
    ls = list(map(int,input().split()))
    for j in ls:
        c[i] |= 1<<(j-1)

dp = [[1e9]*(1<<n) for i in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for S in range(1<<n):
        dp[i+1][S] = min(dp[i+1][S], dp[i][S])
        dp[i+1][S|c[i]] = min(dp[i+1][S|c[i]], dp[i][S]+a[i])
if dp[m][(1<<n)-1] < 1e9:
    print(dp[m][(1<<n)-1])
else:
    print(-1) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a = [None]*m a [None]*m [None] None m c = [0]*m c [0]*m [0] 0 m for i in range(m):
    a[i], b = map(int, input().split())
    ls = list(map(int,input().split()))
    for j in ls:
        c[i] |= 1<<(j-1) i range(m) range m a[i], b = map(int, input().split()) a[i] a i map(int, input().split()) map int input().split() ().split () input split b ls = list(map(int,input().split())) ls list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split for j in ls:
        c[i] |= 1<<(j-1) j ls c[i] |= 1<<(j-1) c[i] c i 1<<(j-1) 1 j-1 j 1 [1e9]*(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) [1e9]*(1<<n) [1e9] 1e9 1<<n 1 n dp = [[1e9]*(1<<n) for i in range(m+1)] dp [[1e9]*(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):
    for S in range(1<<n):
        dp[i+1][S] = min(dp[i+1][S], dp[i][S])
        dp[i+1][S|c[i]] = min(dp[i+1][S|c[i]], dp[i][S]+a[i]) i range(m) range m for S in range(1<<n):
        dp[i+1][S] = min(dp[i+1][S], dp[i][S])
        dp[i+1][S|c[i]] = min(dp[i+1][S|c[i]], dp[i][S]+a[i]) S range(1<<n) range 1<<n 1 n dp[i+1][S] = min(dp[i+1][S], dp[i][S]) dp[i+1][S] [i+1] dp i+1 i 1 S min(dp[i+1][S], dp[i][S]) min dp[i+1][S] [i+1] dp i+1 i 1 S dp[i][S] [i] dp i S dp[i+1][S|c[i]] = min(dp[i+1][S|c[i]], dp[i][S]+a[i]) dp[i+1][S|c[i]] [i+1] dp i+1 i 1 S|c[i] S c[i] c i min(dp[i+1][S|c[i]], dp[i][S]+a[i]) min dp[i+1][S|c[i]] [i+1] dp i+1 i 1 S|c[i] S c[i] c i dp[i][S]+a[i] dp[i][S] [i] dp i S a[i] a i if dp[m][(1<<n)-1] < 1e9:
    print(dp[m][(1<<n)-1])
else:
    print(-1) dp[m][(1<<n)-1] < 1e9 dp[m][(1<<n)-1] [m] dp m (1<<n)-1 1<<n 1 n 1 1e9 print(dp[m][(1<<n)-1]) print dp[m][(1<<n)-1] [m] dp m (1<<n)-1 1<<n 1 n 1 print(-1) print -1 a = [None]*m [None]*m a dp = [[1e9]*(1<<n) for i in range(m+1)] [[1e9]*(1<<n) for i in range(m+1)] dp n, m = map(int, input().split()) map(int, input().split()) n ls = list(map(int,input().split())) list(map(int,input().split())) ls c = [0]*m [0]*m c b = map(int, input().split()) map(int, input().split()) b m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
a = [None]*m
c = [0]*m
for i in range(m):
    a[i], b = map(int, input().split())
    ls = list(map(int,input().split()))
    for j in ls:
        c[i] |= 1<<(j-1)

dp = [[1e9]*(1<<n) for i in range(m+1)]
dp[0][0] = 0
for i in range(m):
    for S in range(1<<n):
        dp[i+1][S] = min(dp[i+1][S], dp[i][S])
        dp[i+1][S|c[i]] = min(dp[i+1][S|c[i]], dp[i][S]+a[i])
if dp[m][(1<<n)-1] < 1e9:
    print(dp[m][(1<<n)-1])
else:
    print(-1)