n,m = map(int,input().split())
INF = 10**10

B = [INF]*(1<<n)
B[0] = 0

for _ in range(m):
  a,b = map(int,input().split())
  C = list(map(int,input().split()))
  opens = 0
  for c in C:
    opens |= (1<<(c-1))
  
  for i in range(2**n):
    if B[i|opens] > B[i]+a:
      B[i|opens] = B[i]+a

if B[(1<<n)-1]==INF:
  print(-1)
else:
  print(B[(1<<n)-1]) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m INF = 10**10 INF 10**10 10 10 B = [INF]*(1<<n) B [INF]*(1<<n) [INF] INF 1<<n 1 n B[0] = 0 B[0] B 0 0 for _ in range(m):
  a,b = map(int,input().split())
  C = list(map(int,input().split()))
  opens = 0
  for c in C:
    opens |= (1<<(c-1))
  
  for i in range(2**n):
    if B[i|opens] > B[i]+a:
      B[i|opens] = B[i]+a _ 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 opens = 0 opens 0 for c in C:
    opens |= (1<<(c-1))
  
   c C opens |= (1<<(c-1)) opens 1<<(c-1) 1 c-1 c 1 for i in range(2**n):
    if B[i|opens] > B[i]+a:
      B[i|opens] = B[i]+a i range(2**n) range 2**n 2 n if B[i|opens] > B[i]+a:
      B[i|opens] = B[i]+a B[i|opens] > B[i]+a B[i|opens] B i|opens i opens B[i]+a B[i] B i a B[i|opens] = B[i]+a B[i|opens] B i|opens i opens B[i]+a B[i] B i a if B[(1<<n)-1]==INF:
  print(-1)
else:
  print(B[(1<<n)-1]) B[(1<<n)-1]==INF B[(1<<n)-1] B (1<<n)-1 1<<n 1 n 1 INF print(-1) print -1 print(B[(1<<n)-1]) print B[(1<<n)-1] B (1<<n)-1 1<<n 1 n 1 b = map(int,input().split()) map(int,input().split()) b opens = 0 0 opens a,b = map(int,input().split()) map(int,input().split()) a C = list(map(int,input().split())) list(map(int,input().split())) C m = map(int,input().split()) map(int,input().split()) m B = [INF]*(1<<n) [INF]*(1<<n) B n,m = map(int,input().split()) map(int,input().split()) n INF = 10**10 10**10 INF opens |= (1<<(c-1)) 1<<(c-1) opens
n,m = map(int,input().split())
INF = 10**10

B = [INF]*(1<<n)
B[0] = 0

for _ in range(m):
  a,b = map(int,input().split())
  C = list(map(int,input().split()))
  opens = 0
  for c in C:
    opens |= (1<<(c-1))
  
  for i in range(2**n):
    if B[i|opens] > B[i]+a:
      B[i|opens] = B[i]+a

if B[(1<<n)-1]==INF:
  print(-1)
else:
  print(B[(1<<n)-1])