N, M = map(int, input().split())

INF = 10**9
dp = [INF]*(1<<N)
dp[0] = 0

for _ in range(M):
  a, b = map(int, input().split())
  c = sum(map(lambda x: 1 << (int(x)-1), input().split()))
  for j in range(1<<N):
    dp[j|c] = min(dp[j|c], dp[j] + a)

ans = dp[-1]

if ans == INF:
  print(-1)
else:
  print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M INF = 10**9 INF 10**9 10 9 dp = [INF]*(1<<N) dp [INF]*(1<<N) [INF] INF 1<<N 1 N dp[0] = 0 dp[0] dp 0 0 for _ in range(M):
  a, b = map(int, input().split())
  c = sum(map(lambda x: 1 << (int(x)-1), input().split()))
  for j in range(1<<N):
    dp[j|c] = min(dp[j|c], dp[j] + 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 = sum(map(lambda x: 1 << (int(x)-1), input().split())) c sum(map(lambda x: 1 << (int(x)-1), input().split())) sum map(lambda x: 1 << (int(x)-1), input().split()) map lambda x: 1 << (int(x)-1) 1 << (int(x)-1) 1 int(x)-1 int(x) int x 1 x input().split() ().split () input split for j in range(1<<N):
    dp[j|c] = min(dp[j|c], dp[j] + a) j range(1<<N) range 1<<N 1 N dp[j|c] = min(dp[j|c], dp[j] + a) dp[j|c] dp j|c j c min(dp[j|c], dp[j] + a) min dp[j|c] dp j|c j c dp[j] + a dp[j] dp j a ans = dp[-1] ans dp[-1] dp -1 if ans == INF:
  print(-1)
else:
  print(ans) ans == INF ans INF print(-1) print -1 print(ans) print ans c = sum(map(lambda x: 1 << (int(x)-1), input().split())) sum(map(lambda x: 1 << (int(x)-1), input().split())) c ans = dp[-1] dp[-1] ans dp = [INF]*(1<<N) [INF]*(1<<N) dp INF = 10**9 10**9 INF a, b = map(int, input().split()) map(int, input().split()) a b = map(int, input().split()) map(int, input().split()) b N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())

INF = 10**9
dp = [INF]*(1<<N)
dp[0] = 0

for _ in range(M):
  a, b = map(int, input().split())
  c = sum(map(lambda x: 1 << (int(x)-1), input().split()))
  for j in range(1<<N):
    dp[j|c] = min(dp[j|c], dp[j] + a)

ans = dp[-1]

if ans == INF:
  print(-1)
else:
  print(ans)