N, M = map(int, input().split())
ls = []
dp = [float('inf')]*(1<<N)
for i in range(M):
  a, b = map(int, input().split())
  c = ['0']*N
  inf = [int(i)-1 for i in input().split()]
  for i in range(b):
    x = inf[i]
    c[x] = '1'
  m = ''.join(c)
  m = int(m,2)
  ls += [(a,m)]
  dp[m] = min(a,dp[m])
dp[0] = 0
for i in range(1<<N):
  for j in range(1<<N):
    dp[i|j] = min(dp[i|j], dp[i]+dp[j])
ans = dp[-1] if dp[-1]!=float('inf') else -1
print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M ls = [] ls [] dp = [float('inf')]*(1<<N) dp [float('inf')]*(1<<N) [float('inf')] float('inf') float 'inf' 1<<N 1 N for i in range(M):
  a, b = map(int, input().split())
  c = ['0']*N
  inf = [int(i)-1 for i in input().split()]
  for i in range(b):
    x = inf[i]
    c[x] = '1'
  m = ''.join(c)
  m = int(m,2)
  ls += [(a,m)]
  dp[m] = min(a,dp[m]) 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 = ['0']*N c ['0']*N ['0'] '0' N int(i)-1 for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i)-1 int(i) int i 1 inf = [int(i)-1 for i in input().split()] inf [int(i)-1 for i in input().split()] for i in range(b):
    x = inf[i]
    c[x] = '1'
   i range(b) range b x = inf[i] x inf[i] inf i c[x] = '1' c[x] c x '1' m = ''.join(c) m ''.join(c) ''.join '' join c m = int(m,2) m int(m,2) int m 2 ls += [(a,m)] ls [(a,m)] (a,m) a m dp[m] = min(a,dp[m]) dp[m] dp m min(a,dp[m]) min a dp[m] dp m dp[0] = 0 dp[0] dp 0 0 for i in range(1<<N):
  for j in range(1<<N):
    dp[i|j] = min(dp[i|j], dp[i]+dp[j]) i range(1<<N) range 1<<N 1 N for j in range(1<<N):
    dp[i|j] = min(dp[i|j], dp[i]+dp[j]) j range(1<<N) range 1<<N 1 N dp[i|j] = min(dp[i|j], dp[i]+dp[j]) dp[i|j] dp i|j i j min(dp[i|j], dp[i]+dp[j]) min dp[i|j] dp i|j i j dp[i]+dp[j] dp[i] dp i dp[j] dp j ans = dp[-1] if dp[-1]!=float('inf') else -1 ans dp[-1] if dp[-1]!=float('inf') else -1 dp[-1]!=float('inf') dp[-1] dp -1 float('inf') float 'inf' dp[-1] dp -1 -1 print(ans) print ans ans = dp[-1] if dp[-1]!=float('inf') else -1 dp[-1] if dp[-1]!=float('inf') else -1 ans ls += [(a,m)] [(a,m)] ls ls = [] [] ls N, M = map(int, input().split()) map(int, input().split()) N c = ['0']*N ['0']*N c b = map(int, input().split()) map(int, input().split()) b m = ''.join(c) ''.join(c) m x = inf[i] inf[i] x m = int(m,2) int(m,2) m dp = [float('inf')]*(1<<N) [float('inf')]*(1<<N) dp a, b = map(int, input().split()) map(int, input().split()) a M = map(int, input().split()) map(int, input().split()) M inf = [int(i)-1 for i in input().split()] [int(i)-1 for i in input().split()] inf
N, M = map(int, input().split())
ls = []
dp = [float('inf')]*(1<<N)
for i in range(M):
  a, b = map(int, input().split())
  c = ['0']*N
  inf = [int(i)-1 for i in input().split()]
  for i in range(b):
    x = inf[i]
    c[x] = '1'
  m = ''.join(c)
  m = int(m,2)
  ls += [(a,m)]
  dp[m] = min(a,dp[m])
dp[0] = 0
for i in range(1<<N):
  for j in range(1<<N):
    dp[i|j] = min(dp[i|j], dp[i]+dp[j])
ans = dp[-1] if dp[-1]!=float('inf') else -1
print(ans)
