n,m = gets.chomp.split(" ").map(&:to_i)
a = Array.new(m)
b = Array.new(m)
c = Array.new(m)
m.times do |i|
  a[i],b[i] = gets.chomp.split(" ").map(&:to_i)
  c[i] = gets.chomp.split(" ").map(&:to_i)
end
dp = Array.new(2.pow(n),100000000000)
dp[0] = 0
for i in 1..m
  bits = 0
  c[i-1].each do |x|
    bits += 2.pow(x-1)
  end
  for j in 0..2.pow(n)-1
    dp[j|bits] = [dp[j|bits], dp[j]+a[i-1]].min
  end
end
puts dp[2.pow(n)-1] != 100000000000 ? dp[2.pow(n)-1] : -1