local mfl = math.floor
local function getor(x, y)
  local ret = 0
  local mul = 1
  while(0 < x or 0 < y) do
    if((x % 2) + (y % 2) ~= 0) then
      ret = ret + mul
    end
    x, y, mul = mfl(x / 2), mfl(y / 2), mul * 2
  end
  return ret
end

local n, m = io.read("*n", "*n")
local tot = 1
for i = 1, n do
  tot = tot * 2
end
local t = {}
for i = 1, tot do
  t[i] = -1
end
t[1] = 0
for i = 1, m do
  local a, b = io.read("*n", "*n")
  local c = {}
  for j = 1, b do
    c[io.read("*n")] = true
  end
  local val = 0
  local v = 1
  for j = 1, n do
    if c[j] then
      val = val + v
    end
    v = v * 2
  end
  for src = tot, 1, -1 do
    if 0 <= t[src] then
      local dst = 1 + getor(src - 1, val)
      if t[dst] == -1 or t[src] + a < t[dst] then
        t[dst] = t[src] + a
      end
    end
  end
end
print(t[tot])
