require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n, @m = gets.chomp.split.map(&:to_i)
@a = []
@m.times do
  ai, bi = gets.chomp.split.map(&:to_i)
  @a.push [ai, gets.chomp.split.map(&:to_i)]
end

@goal_bits = (1 << n) - 1
@memo = Array.new(@m){Array.new(@goal_bits + 1)}

def solve(index, bits)
  return 0 if bits == @goal_bits
  return INF if index == @m
  return @memo[index][bits] if @memo[index][bits]
  ret1 = solve(index + 1, bits)
  @a[index][1].each do |c|
    bits |= 1 << (c - 1)
  end
  ret2 = @a[index][0] + solve(index + 1, bits)
  @memo[index][bits] = [ret1, ret2].min
end

ans = solve(0, 0)
if ans == INF
  puts -1
else
  puts ans
end
