N,M = map(int,input().split())
keys = []
for _ in range(M):
  a,b = map(int,input().split())

  s = 0
  for c in list(map(int,input().split())):
    c -= 1
    s = s | 1<<c

  keys.append((s, a))


# dp[i][j] = Nの状態の鍵を用いた時に、Mの鍵を開けるための最小コスト
dp = [float('inf')] * (1<<N)
dp[0] = 0
for s in range(1<<N):
  for i in range(M):
    t = s | keys[i][0]
    cost = dp[s] + keys[i][1]
    dp[t] = min(dp[t], cost)

if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1]) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M keys = [] keys [] for _ in range(M):
  a,b = map(int,input().split())

  s = 0
  for c in list(map(int,input().split())):
    c -= 1
    s = s | 1<<c

  keys.append((s, a))


# dp[i][j] = Nの状態の鍵を用いた時に、Mの鍵を開けるための最小コスト _ range(M) range M a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b s = 0 s 0 for c in list(map(int,input().split())):
    c -= 1
    s = s | 1<<c

   c list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split c -= 1 c 1 s = s | 1<<c s s | 1<<c s 1<<c 1 c keys.append((s, a)) keys.append keys append (s, a) s a dp = [float('inf')] * (1<<N) dp [float('inf')] * (1<<N) [float('inf')] float('inf') float 'inf' 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for s in range(1<<N):
  for i in range(M):
    t = s | keys[i][0]
    cost = dp[s] + keys[i][1]
    dp[t] = min(dp[t], cost) s range(1<<N) range 1<<N 1 N for i in range(M):
    t = s | keys[i][0]
    cost = dp[s] + keys[i][1]
    dp[t] = min(dp[t], cost) i range(M) range M t = s | keys[i][0] t s | keys[i][0] s keys[i][0] [i] keys i 0 cost = dp[s] + keys[i][1] cost dp[s] + keys[i][1] dp[s] dp s keys[i][1] [i] keys i 1 dp[t] = min(dp[t], cost) dp[t] dp t min(dp[t], cost) min dp[t] dp t cost if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1]) dp[-1] == float('inf') dp[-1] dp -1 float('inf') float 'inf' print(-1) print -1 print(dp[-1]) print dp[-1] dp -1 M = map(int,input().split()) map(int,input().split()) M keys = [] [] keys s = 0 0 s t = s | keys[i][0] s | keys[i][0] t b = map(int,input().split()) map(int,input().split()) b a,b = map(int,input().split()) map(int,input().split()) a N,M = map(int,input().split()) map(int,input().split()) N c -= 1 1 c dp = [float('inf')] * (1<<N) [float('inf')] * (1<<N) dp cost = dp[s] + keys[i][1] dp[s] + keys[i][1] cost s = s | 1<<c s | 1<<c s
N,M = map(int,input().split())
keys = []
for _ in range(M):
  a,b = map(int,input().split())

  s = 0
  for c in list(map(int,input().split())):
    c -= 1
    s = s | 1<<c

  keys.append((s, a))


# dp[i][j] = Nの状態の鍵を用いた時に、Mの鍵を開けるための最小コスト
dp = [float('inf')] * (1<<N)
dp[0] = 0
for s in range(1<<N):
  for i in range(M):
    t = s | keys[i][0]
    cost = dp[s] + keys[i][1]
    dp[t] = min(dp[t], cost)

if dp[-1] == float('inf'):
  print(-1)
else:
  print(dp[-1])