CF1108A.Two distinct points

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 < r_1 and l2<r2l_2 < 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.

输入格式

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} ( 1l1i,r1i,l2i,r2i109,l1i<r1i,l2i<r2i1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} < r_{1_i}, l_{2_i} < r_{2_i} ) — the ends of the segments in the ii -th query.

输出格式

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.

输入输出样例

  • 输入#1

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

    输出#1

    2 1
    3 4
    3 2
    1 2
    3 7
    
首页