The first formal set of axioms for origami was published by Humiaki Huzita and Benedetto Scimemi and is known as the Huzita axioms. Each axiom describes a way in which a single fold line can be produced by aligning points and lines. One version of the six axioms is:
The sixth axiom is the hard one: a single straight fold must simultaneously reflect $p_1$ onto line $l_1$ and $p_2$ onto line $l_2$. Depending on the configuration there may be no such fold, or one, two, or three of them.
For each test case, determine how many distinct fold lines satisfy the sixth axiom — that is, how many distinct straight lines reflect $p_1$ onto $l_1$ and $p_2$ onto $l_2$ at the same time.
The first line contains the number of test cases $t$ ($1 \le t \le 20000$).
Each test case is given on exactly four lines, describing $l_1$, $p_1$, $l_2$ and $p_2$ in that order:
All coordinates are integers with absolute value at most $10$. It is guaranteed that $p_1$ does not lie on $l_1$ and $p_2$ does not lie on $l_2$. The lines $l_1$ and $l_2$ are different, but the points $p_1$ and $p_2$ may coincide.
For each test case output a single line containing one integer: the number of distinct fold lines that place $p_1$ onto $l_1$ and $p_2$ onto $l_2$. This value is always $0$, $1$, $2$, or $3$.
A fold that reflects a point $p$ onto a line $l$ is exactly a tangent line to the parabola whose focus is $p$ and whose directrix is $l$. A fold satisfying the sixth axiom is therefore a common tangent of the parabola $(p_1, l_1)$ and the parabola $(p_2, l_2)$. Two distinct parabolas share at most three ordinary common tangents, which is why the answer never exceeds three. When $l_1$ and $l_2$ are parallel the number of common tangents can drop to two, one, or zero.