program main
  implicit none
  integer :: n, k, m, p, i, j, j2, j3, a, b, c(1000)
  integer, allocatable :: dp(:)
  read *, n, m
  k = 2 ** n
  allocate (dp(0:k - 1))
  dp = 10 ** 9
  dp(0) = 0

  do i = 1, m
    read *, a, b
    read *, c(1:b)
    j3 = 0
    do p = 1, b
      j3 = ibset(j3, c(p) - 1)
    end do
    do j = k - 1, 0, -1  ! 配る
      j2 = ior(j, j3)
      dp(j2) = min(dp(j2), dp(j) + a)
    end do
  end do
  if (dp(k - 1) == 10 ** 9) dp(k - 1) = -1
  print "(i0)", dp(k - 1)
end program main
