CF1297B.Cartoons

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The first line contains single integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. The following are descriptions of the tt test cases.

The first line of each test case contains a single integer nn ( 1n20001 \le n \le 2000 ) — the number of cartoons.

In the next nn lines, the cartoons themselves are described, one per line, by a pair of integers aia_i , bib_i ( 1aibi1091 \le a_i \le b_i \le 10^9 ) — the first and last airing days for the ii -th cartoon.

It is guaranteed that the sum of the values nn for all test cases in the input does not exceed 20002000 .

输入格式

Print tt answers to given test cases in the order in which they appear in the input: the ii -th answer is such xx , that only one cartoon will be airing on day xx or -1 if there are no such days.

输出格式

In the third test case: at day 11 and 22 , first and third cartoons will be airing, and days 33 and 44 , second and third cartoons will be airing. So, there is no day when only one cartoon will be airing.

In the fourth test case, 1111 is also a possible answer.

输入输出样例

  • 输入#1

    5
    1
    1 1
    3
    2 1000000000
    2 500000000
    500000002 1000000000
    3
    1 2
    3 4
    1 4
    2
    4 11
    4 9
    3
    1 5
    10 10
    1 5

    输出#1

    1
    500000001
    -1
    10
    10

说明/提示

In the third test case: at day 11 and 22 , first and third cartoons will be airing, and days 33 and 44 , second and third cartoons will be airing. So, there is no day when only one cartoon will be airing.

In the fourth test case, 1111 is also a possible answer.

首页