gets.to_i.times do
  p0, p1, p2, p3 = gets.split.map(&:to_i).each_slice(2).map {|a, b| a + b * 1i }
  u, v, w = p1 - p0, p3 - p2, p2 - p0, p3 - p0
  t = (Complex(*v.rect.reverse!) * w).real.to_f / (u.conj * v).imag
  puts '%.8f %.8f' % (p0 + t * u).rect
end