n,m = map(int, input().split())
dp = [0]*(2**n + 1)
for i in range(m):
  a,b = map(int, input().split())
  c = list(map(int, input().split()))
  temp=0
  for i in c:
    temp += 2 ** (i-1)
  for i in range(2**n):
    if i != 0 and dp[i] == 0:
      continue
    t = i | temp
    if dp[t] == 0:
      dp[t] = dp[i] + a
    else:
      dp[t] = min(dp[i] + a, dp[t])

ans = dp[2**n - 1]
if ans == 0:
  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 = [0]*(2**n + 1) dp [0]*(2**n + 1) [0] 0 2**n + 1 2**n 2 n 1 for i in range(m):
  a,b = map(int, input().split())
  c = list(map(int, input().split()))
  temp=0
  for i in c:
    temp += 2 ** (i-1)
  for i in range(2**n):
    if i != 0 and dp[i] == 0:
      continue
    t = i | temp
    if dp[t] == 0:
      dp[t] = dp[i] + a
    else:
      dp[t] = min(dp[i] + a, dp[t]) 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 = list(map(int, input().split())) c list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split temp=0 temp 0 for i in c:
    temp += 2 ** (i-1)
   i c temp += 2 ** (i-1) temp 2 ** (i-1) 2 i-1 i 1 for i in range(2**n):
    if i != 0 and dp[i] == 0:
      continue
    t = i | temp
    if dp[t] == 0:
      dp[t] = dp[i] + a
    else:
      dp[t] = min(dp[i] + a, dp[t]) i range(2**n) range 2**n 2 n if i != 0 and dp[i] == 0:
      continue
     i != 0 and dp[i] == 0 i != 0 i 0 dp[i] == 0 dp[i] dp i 0 continue t = i | temp t i | temp i temp if dp[t] == 0:
      dp[t] = dp[i] + a
    else:
      dp[t] = min(dp[i] + a, dp[t]) dp[t] == 0 dp[t] dp t 0 dp[t] = dp[i] + a dp[t] dp t dp[i] + a dp[i] dp i a dp[t] = min(dp[i] + a, dp[t]) dp[t] dp t min(dp[i] + a, dp[t]) min dp[i] + a dp[i] dp i a dp[t] dp t ans = dp[2**n - 1] ans dp[2**n - 1] dp 2**n - 1 2**n 2 n 1 if ans == 0:
  print(-1)
else:
  print(ans) ans == 0 ans 0 print(-1) print -1 print(ans) print ans b = map(int, input().split()) map(int, input().split()) b c = list(map(int, input().split())) list(map(int, input().split())) c m = map(int, input().split()) map(int, input().split()) m temp=0 0 temp t = i | temp i | temp t a,b = map(int, input().split()) map(int, input().split()) a n,m = map(int, input().split()) map(int, input().split()) n temp += 2 ** (i-1) 2 ** (i-1) temp dp = [0]*(2**n + 1) [0]*(2**n + 1) dp ans = dp[2**n - 1] dp[2**n - 1] ans
n,m = map(int, input().split())
dp = [0]*(2**n + 1)
for i in range(m):
  a,b = map(int, input().split())
  c = list(map(int, input().split()))
  temp=0
  for i in c:
    temp += 2 ** (i-1)
  for i in range(2**n):
    if i != 0 and dp[i] == 0:
      continue
    t = i | temp
    if dp[t] == 0:
      dp[t] = dp[i] + a
    else:
      dp[t] = min(dp[i] + a, dp[t])

ans = dp[2**n - 1]
if ans == 0:
  print(-1)
else:
  print(ans)