n = gets.to_i
n.times do
    a = gets.split.map(&:to_i)
    v1 = a[0..3]
    v2 = a[4..7]
    tab = [
        [1, 2, 3, 4],
        [2, -1, 4, -3],
        [3, -4, -1, 2],
        [4, 3, -2, -1]
    ]
    prod = [0, 0, 0, 0]
    (0..3).to_a.repeated_permutation(2).each do |i, j|
        if tab[i][j] > 0
            prod[tab[i][j]-1] += v1[i] * v2[j]
        else
            prod[-tab[i][j]-1] -= v1[i] * v2[j]
        end
    end
    puts prod * ' '
end
