N,M = map(int,input().split())
dp = [float('inf')]*2 ** N
dp[0] = 0
for _ in range(M):
  a, b = map(int, input().split())
  c = sum([2**(int(i)-1) for i in input().split()])
  for s in range(2**N):
    t = s|c
    if dp[t] > dp[s] + a:
      dp[t] = dp[s] +a
ans = dp[-1]
if dp[-1] == float('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 dp = [float('inf')]*2 ** N dp [float('inf')]*2 ** N [float('inf')] float('inf') float 'inf' 2 ** N 2 N dp[0] = 0 dp[0] dp 0 0 for _ in range(M):
  a, b = map(int, input().split())
  c = sum([2**(int(i)-1) for i in input().split()])
  for s in range(2**N):
    t = s|c
    if dp[t] > dp[s] + a:
      dp[t] = dp[s] +a _ range(M) range M a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b 2**(int(i)-1) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() 2**(int(i)-1) 2 int(i)-1 int(i) int i 1 c = sum([2**(int(i)-1) for i in input().split()]) c sum([2**(int(i)-1) for i in input().split()]) sum [2**(int(i)-1) for i in input().split()] for s in range(2**N):
    t = s|c
    if dp[t] > dp[s] + a:
      dp[t] = dp[s] +a s range(2**N) range 2**N 2 N t = s|c t s|c s c if dp[t] > dp[s] + a:
      dp[t] = dp[s] +a dp[t] > dp[s] + a dp[t] dp t dp[s] + a dp[s] dp s a dp[t] = dp[s] +a dp[t] dp t dp[s] +a dp[s] dp s a ans = dp[-1] ans dp[-1] dp -1 if dp[-1] == float('inf'):
  print(-1)
else:
  print(ans) dp[-1] == float('inf') dp[-1] dp -1 float('inf') float 'inf' print(-1) print -1 print(ans) print ans N,M = map(int,input().split()) map(int,input().split()) N M = map(int,input().split()) map(int,input().split()) M b = map(int, input().split()) map(int, input().split()) b c = sum([2**(int(i)-1) for i in input().split()]) sum([2**(int(i)-1) for i in input().split()]) c dp = [float('inf')]*2 ** N [float('inf')]*2 ** N dp t = s|c s|c t ans = dp[-1] dp[-1] ans a, b = map(int, input().split()) map(int, input().split()) a
N,M = map(int,input().split())
dp = [float('inf')]*2 ** N
dp[0] = 0
for _ in range(M):
  a, b = map(int, input().split())
  c = sum([2**(int(i)-1) for i in input().split()])
  for s in range(2**N):
    t = s|c
    if dp[t] > dp[s] + a:
      dp[t] = dp[s] +a
ans = dp[-1]
if dp[-1] == float('inf'):
  print(-1)
else:
  print(ans)