Medium Beginners Problems > Ad-hoc
Sanvi is a teacher. She lost exam answer sheets of students. So, she is planning to provide same marks to every student. For each student, she knows in advance the lower bound and upper bound of marks that make them happy. Now, she asks your help to count the total number of different marks that make at least **P** students happy. Input: ------ Input starts with an integer **T (1<=T<=20)**, denoting the number of test cases. Each case starts with two space separated integers **N (1 ≤ N ≤ 10000)** denoting the number of students and . **P (1 ≤ P ≤ N )** .The next N lines will contain two space separated integers **( Li and Ri, Li<=Ri , Li>=1 and Ri<=100000 )** denoting lowerbound and upper bound of marks that make ith student happy. Output: ------- For each case of input, output the total number of different marks that make at least **P** student happy. Sample Input ------------ 1 3 2 1 10 8 12 12 15 Sample Output ------------- 4 Explanation:<br> For the given sample, If Sanvi provide marks either of 8,9,10 or 12, at least 2 student will be happy.