program get_everything
    implicit none

    integer(4):: n,m,i,j
    integer(4),allocatable:: a(:), b(:),c(:),key(:), dp(:)
    integer(4),parameter:: inf=1000000001

    read*, n,m
    allocate(a(m), b(m), key(m))
    allocate(dp(0:2**n-1))
    dp(:) = inf
    dp(0) = 0

    do i=1,m
        read*,a(i),b(i)
        allocate(c(b(i)))
        read*,c(:)
        key(i) = sum(2**(c(:)-1))
        deallocate(c)
    end do

    do i=0,2**n-1
        do j=1,m
            dp(or(i,key(j))) = min(dp(or(i,key(j))),dp(i)+a(j))
        end do
    end do

    if (dp(2**n-1) == inf) then
        print*, -1
    else
        print*, dp(2**n-1)
    end if

end program get_everything