### main

loop do
  n = gets.to_i
  break if n == 0

  tbls = []
  (n - 1).times do
    mi = gets.to_i
    tbli = []
    mi.times do
      xij, yij, cij = gets.split.map(&:to_i)
      tbli << [xij, yij, cij]
    end
    tbls << tbli.sort
  end
  #p tbls

  g = gets.to_i

  sts = [[0, 0]]
  to = {}

  for i in (0...(n - 1))
    tbli = tbls[i]
    to = {}

    for st in sts
      ti, ci = st

      for tbl in tbli
        xij, yij, cij = tbl

        if xij >= ti
          ci0 = ci + cij
          if to[yij].nil?
            to[yij] = [yij, ci0]
          elsif to[yij][1] > ci0
            to[yij][1] = ci0
          end
        end
      end

      sts = to.values.sort
    end
  end

  gls = to.values.sort{|a, b| a[1] <=> b[1]}

  len = (gls.length < g) ? gls.length : g
  c = 0

  for i in (0...len)
    c += gls[i][1]
  end

  puts [len, c].join(' ')
end