N,M=gets.split.map(&:to_i)
as=Array.new
cs=Array.new
M.times do
  a,b=gets.split.map(&:to_i)
  as << a
  cs << gets.split.map(&:to_i).map{|e|(1<<(e-1))}.inject(:+)
end
dp=Array.new(M+1){Array.new(2**N,Float::INFINITY)}
dp[0][0]=0
for i in 1..M
  for j in 0...2**N
    dp[i][j]=dp[i-1][j] < dp[i][j] ? dp[i-1][j] : dp[i][j]
    dp[i][j | cs[i-1]] = (dp[i-1][j]+as[i-1]) < dp[i][j | cs[i-1]] ? (dp[i-1][j]+as[i-1]) : dp[i][j | cs[i-1]]
  end
end
p dp[M][2**N-1]==Float::INFINITY ? Float::INFINITY : dp[M][2**N-1]
    
  