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

INF = 10**9
dp = [[INF]*(1<<N) for _ in range(M+1)]
dp[0][0] = 0

for i 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):
    k = j|c
    dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    dp[i+1][k] = min(dp[i+1][k], dp[i][k], dp[i][j] + a)

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

INF = 10**9
dp = [[INF]*(1<<N) for _ in range(M+1)]
dp[0][0] = 0

for i 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):
    k = j|c
    dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    dp[i+1][k] = min(dp[i+1][k], dp[i][k], dp[i][j] + a)

ans = dp[-1][-1]

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