local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local N, M = read.nn()
local KCost = {}
local KAbl = {}
for i=1,M do
    local a, b = read.nn()
    KCost[i] = a
    KAbl[i] = 0
    for j=1,b do
        local c = read.n()
        local bit = 1 << (c-1)
        KAbl[i] = KAbl[i] | bit
    end
end


local curset = 0
local STATMAX = math.floor(2^N) - 1

local INF = 10^9
local cost = array(1, INF)
cost[0] = 0
local min = math.min
local function chmin(s, val)
    cost[s] = min(cost[s], val)
end

for stat=0,STATMAX do
    if cost[stat] ~= INF then
        for curkey=1,M do
            local newstat = stat | KAbl[curkey]
            chmin(newstat, cost[stat] + KCost[curkey])
        end
    end
end

if cost[STATMAX] == INF then
    print("-1")
    return
end

print(cost[STATMAX])
