# after listening explanation
n, m = gets.split.map(&:to_i)
key = []
m.times{
  a,b = gets.split.map(&:to_i)
  c = gets.split.map(&:to_i)
  state = c.map{|ci| 1<<(ci-1)}.inject(:+)
  key << [state, a]
}
dp = Array.new(1<<n)
dp[0] = 0
(1<<n).times{|state_s|
  next if dp[state_s] == nil
  m.times{|i|
    state_t = state_s | key[i][0]
    cost = dp[state_s] + key[i][1]
    dp[state_t] = dp[state_t]==nil ? cost : [dp[state_t], cost].min
  }
}
ans = dp.last
p ans==nil ? -1 : ans