CF1108A.Two distinct points

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Two distinct points

You are given two segments [l1;r1][l_1; r_1] and [l2;r2][l_2; r_2] on the xx-axis. It is guaranteed that l1<r1l_1 \lt r_1 and l2<r2l_2 \lt r_2. Segments may intersect, overlap or even coincide with each other.

The example of two segments on the xx-axis.

Your problem is to find two integers aa and bb such that l1ar1l_1 \le a \le r_1, l2br2l_2 \le b \le r_2 and aba \ne b. In other words, you have to choose two distinct integer points in such a way that the first point belongs to the segment [l1;r1][l_1; r_1] and the second one belongs to the segment [l2;r2][l_2; r_2].

It is guaranteed that the answer exists. If there are multiple answers, you can print any of them.

You have to answer qq independent queries.

Input

The first line of the input contains one integer qq (1q5001 \le q \le 500) — the number of queries.

Each of the next qq lines contains four integers l1i,r1i,l2il_{1_i}, r_{1_i}, l_{2_i} and r2ir_{2_i} ($1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} \lt r_{1_i}, l_{2_i} \lt r_{2_i}$) — the ends of the segments in the ii-th query.

Output

Print 2q2q integers. For the ii-th query print two integers aia_i and bib_i — such numbers that l1iair1il_{1_i} \le a_i \le r_{1_i}, l2ibir2il_{2_i} \le b_i \le r_{2_i} and aibia_i \ne b_i. Queries are numbered in order of the input.

It is guaranteed that the answer exists. If there are multiple answers, you can print any.

Samples

5
1 2 1 2
2 6 3 4
2 4 1 3
1 2 1 3
1 4 5 8
2 1
3 4
3 2
1 2
3 7

在线编程 IDE

建议全屏模式获得最佳体验