409050: GYM103427 I Linear Fractional Transformation
Description
The linear fractional transformations are the functions $$$f(z)=\frac{az+b}{cz+d}$$$ $$$(a,b,c,d \in \mathbb{C}, ad-bc \neq 0)$$$ mapping the extended complex plane $$$\mathbb{C} \cup \{ \infty \}$$$ onto itself.
Given $$$f(z_1) = w_1$$$, $$$f(z_2) = w_2$$$ and $$$f(z_3) = w_3$$$, where $$$z_1$$$, $$$z_2$$$ and $$$z_3$$$ are pairwise distinct complex numbers and $$$w_1$$$, $$$w_2$$$ and $$$w_3$$$ are also pairwise distinct complex numbers, your task is to calculate $$$f(z_0)$$$ for a certain complex number $$$z_0$$$. It can be shown that the answer is always unique to the given contraints.
InputThe input contains several test cases, and the first line contains an integer $$$T$$$ $$$(1 \le T \le 10^5)$$$, indicating the number of test cases.
To clarify the input format, we denote $$$z_0=p_0+q_0i$$$, $$$z_1=p_1+q_1i$$$, $$$z_2=p_2+q_2i$$$, $$$z_3=p_3+q_3i$$$, $$$w_1=r_1+s_1i$$$, $$$w_2=r_2+s_2i$$$ and $$$w_3=r_3+s_3i$$$, where $$$i$$$ is the imaginary unit that $$$i^2=-1$$$.
Then for each test case, the first line contains four integers $$$p_1$$$, $$$q_1$$$, $$$r_1$$$ and $$$s_1$$$, the second contains four integers $$$p_2$$$, $$$q_2$$$, $$$r_2$$$ and $$$s_2$$$, the third line contains four integers $$$p_3$$$, $$$q_3$$$, $$$r_3$$$ and $$$s_3$$$, and the fourth line contains only two integers $$$p_0$$$ and $$$q_0$$$. It is guaranteed that all these integers are in the range $$$[-100,100]$$$ and the answer $$$f(z_0)$$$ satisfies $$$|f(z_0)| < 10^6$$$, where $$$|z|=|p+qi|=\sqrt{p^2+q^2}$$$ $$$(p, q \in \mathbb{R})$$$ is the modulus of the complex number $$$z$$$.
OutputFor each test case, output a line containing two real numbers $$$c_0$$$ and $$$d_0$$$, indicating the real part and the imaginary part of $$$f(z_0)$$$.
Your answer is acceptable if the absolute or relative errors of both the real part and the imaginary part do not exceed $$$10^{-6}$$$. Formally speaking, suppose that your output is $$$x$$$ and the jury's answer is $$$y$$$, your output is accepted if and only if $$$\frac{|x - y|}{\max(1, |y|)} \leq 10^{-6}$$$.
ExampleInput2 -1 0 0 -1 0 1 -1 0 1 0 0 1 0 -1 -1 0 -1 0 0 1 0 -1 1 0 1 0 0 -1Output
1.000000000000000 0.000000000000000 0.000000000000000 1.000000000000000Note
In the first sample case we have $$$f(z)=iz$$$, and in the second sample case we have $$$f(z)=1/z$$$.