N,M=gets.split.map(&:to_i)
as=Array.new
cs=Array.new
INF=10e9
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(2**N,INF)
dp[0]=0
1.upto(M) do |i|
  dp_next=Array.new(2**N,INF)
  2**N.times do |j|
    a=dp_next[j]
    b=dp[j]
    dp_next[j]= b<a ? b : a
    a=dp_next[j | cs[i-1]]
    b=dp[j]+as[i-1]
    dp_next[j | cs[i-1]]= b<a ? b : a
  end
  dp=dp_next.clone
end
p dp[2**N-1]==INF ? -1 : dp[2**N-1]
    
  