308516: CF1533A. Travel to Bertown
Description
Vika has decided to go on a trip to Bertown. She comes to Bertown on the $k$-th day. Vika does not want to spend money on hotels, fortunately she has $n$ friends who live in Bertown and allow Vika to stay at their houses. The $i$-th friend told Vika that she could stay at their house from the $l_i$-th day till the $r_i$-th day, inclusive.
Vika decided that she would stay at no more than one friend's house. Help Vika determine the maximum number of days that she will be able to stay in Bertown.
InputThe first line contains a single integer $t$ ($1 \le t \le 500$) — the number of test cases.
The first line of each test case contains two integers $n$ and $k$ ($1 \le n, k \le 100$) — the number of Vika's friends and the day when Vika comes to Bertown.
Then follow $n$ lines, each containing two integers $l_i$ and $r_i$ ($1 \le l_i \le r_i \le 100$) denoting the period when Vika can stay at the $i$-th friend's house.
OutputFor each test case, output a single integer — the maximum number of days that Vika can stay in Bertown (or $0$ if none of Vika's friends can host her on day $k$).
ExampleInput3 3 3 1 4 2 6 4 10 2 4 2 3 5 8 2 4 4 4 1 3Output
4 0 1Note
In the first example, Vika can stay at the $2$-nd friend's house from $3$-rd to $6$-th day.
In the second example, none of Vika's friends can host her on the $4$-th day.
In the third example, Vika can stay at the $1$-st friend's house, but only for the $4$-th day.