n, m = map(int,input().split())
a = [0]
b = [0]
c = [0]*(m+1)
for i in range(1, m+1):
    tab = list(map(int, input().split()))
    a.append(tab.pop(0))
    b.append(tab)
    tc1 = list(map(int, input().split()))
    tc2 = 0
    for j in tc1:
        tc2 |= 1<<(j-1)
    c[i] = tc2
INF = 10**9
dp = [[0] + [INF] * (2**n-1) for i in range(m+1)]
for i in range(1, m+1):
    for j in range(2**n):
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        nj = j | c[i]
        dp[i][nj] = min(dp[i][nj], dp[i-1][nj], dp[i-1][j] + a[i])

print(-1) if dp[m][2**n-1] == INF else print(dp[m][2**n-1]) n, m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m a = [0] a [0] 0 b = [0] b [0] 0 c = [0]*(m+1) c [0]*(m+1) [0] 0 m+1 m 1 for i in range(1, m+1):
    tab = list(map(int, input().split()))
    a.append(tab.pop(0))
    b.append(tab)
    tc1 = list(map(int, input().split()))
    tc2 = 0
    for j in tc1:
        tc2 |= 1<<(j-1)
    c[i] = tc2 i range(1, m+1) range 1 m+1 m 1 tab = list(map(int, input().split())) tab list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split a.append(tab.pop(0)) a.append a append tab.pop(0) tab.pop tab pop 0 b.append(tab) b.append b append tab tc1 = list(map(int, input().split())) tc1 list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split tc2 = 0 tc2 0 for j in tc1:
        tc2 |= 1<<(j-1)
     j tc1 tc2 |= 1<<(j-1) tc2 1<<(j-1) 1 j-1 j 1 c[i] = tc2 c[i] c i tc2 INF = 10**9 INF 10**9 10 9 [0] + [INF] * (2**n-1) 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) [0] + [INF] * (2**n-1) [0] 0 [INF] * (2**n-1) [INF] INF 2**n-1 2**n 2 n 1 dp = [[0] + [INF] * (2**n-1) for i in range(m+1)] dp [[0] + [INF] * (2**n-1) for i in range(m+1)] for i in range(1, m+1):
    for j in range(2**n):
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        nj = j | c[i]
        dp[i][nj] = min(dp[i][nj], dp[i-1][nj], dp[i-1][j] + a[i]) i range(1, m+1) range 1 m+1 m 1 for j in range(2**n):
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        nj = j | c[i]
        dp[i][nj] = min(dp[i][nj], dp[i-1][nj], dp[i-1][j] + a[i]) j range(2**n) range 2**n 2 n dp[i][j] = min(dp[i][j], dp[i-1][j]) dp[i][j] [i] dp i 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 nj = j | c[i] nj j | c[i] j c[i] c i dp[i][nj] = min(dp[i][nj], dp[i-1][nj], dp[i-1][j] + a[i]) dp[i][nj] [i] dp i nj min(dp[i][nj], dp[i-1][nj], dp[i-1][j] + a[i]) min dp[i][nj] [i] dp i nj dp[i-1][nj] [i-1] dp i-1 i 1 nj dp[i-1][j] + a[i] dp[i-1][j] [i-1] dp i-1 i 1 j a[i] a i print(-1) if dp[m][2**n-1] == INF else print(dp[m][2**n-1]) dp[m][2**n-1] == INF dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 INF print(-1) print -1 print(dp[m][2**n-1]) print dp[m][2**n-1] [m] dp m 2**n-1 2**n 2 n 1 c = [0]*(m+1) [0]*(m+1) c tc2 = 0 0 tc2 tc2 |= 1<<(j-1) 1<<(j-1) tc2 dp = [[0] + [INF] * (2**n-1) for i in range(m+1)] [[0] + [INF] * (2**n-1) for i in range(m+1)] dp nj = j | c[i] j | c[i] nj m = map(int,input().split()) map(int,input().split()) m tab = list(map(int, input().split())) list(map(int, input().split())) tab n, m = map(int,input().split()) map(int,input().split()) n INF = 10**9 10**9 INF a = [0] [0] a tc1 = list(map(int, input().split())) list(map(int, input().split())) tc1 b = [0] [0] b
n, m = map(int,input().split())
a = [0]
b = [0]
c = [0]*(m+1)
for i in range(1, m+1):
    tab = list(map(int, input().split()))
    a.append(tab.pop(0))
    b.append(tab)
    tc1 = list(map(int, input().split()))
    tc2 = 0
    for j in tc1:
        tc2 |= 1<<(j-1)
    c[i] = tc2
INF = 10**9
dp = [[0] + [INF] * (2**n-1) for i in range(m+1)]
for i in range(1, m+1):
    for j in range(2**n):
        dp[i][j] = min(dp[i][j], dp[i-1][j])
        nj = j | c[i]
        dp[i][nj] = min(dp[i][nj], dp[i-1][nj], dp[i-1][j] + a[i])

print(-1) if dp[m][2**n-1] == INF else print(dp[m][2**n-1])