#HK6974. 「ICPC World Finals 2024」双人马背摔跤

「ICPC World Finals 2024」双人马背摔跤

Description

The Nomadic Games Exploratory Committee (NGEC) is floating the idea of a doubles horseback wrestling tournament with pairs of riders astride single horses. They have advertised a pilot tournament, and nn eager riders have signed up to compete! So now the NGEC needs to pair the riders in order to make the tournament both fair and exciting.

The Central Asian Audaryspak League (CAAL) maintains a list of all horseback wrestlers and their ratings. From their previous experience with ordinary horseback wrestling, the NGEC has decided that the pairs are best balanced if the ratings of their two riders add up to a particular integer, ss.

For obscure licensing reasons, the CAAL refuses to release the exact rating of each rider. But the NGEC has some good estimates, knowing that any rider ii 's true rating rir_{i} lies in an interval [li,ui]\left[l_{i}, u_{i}\right]. So the NGEC would consider pairing two riders ii and jj if there are ratings ri[li,ui]r_{i} \in\left[l_{i}, u_{i}\right] and rj[lj,uj]r_{j} \in\left[l_{j}, u_{j}\right] such that ri+rj=sr_{i}+r_{j}=s.

The NGEC wants to form as many non-intersecting pairs of riders as possible. You need to help them.

Input

The first line contains two integers nn and ss (2n2105,1s1092 \leq n \leq 2 \cdot 10^{5}, 1 \leq s \leq 10^{9}), denoting the number of riders and the desired sum of ratings of riders in a pair. Riders are numbered 1 to nn. This is followed by nn lines, where the ithi^{\text {th}} line contains two integers lil_{i} and uiu_{i} (1liui1091 \leq l_{i} \leq u_{i} \leq 10^{9}), denoting the rating range of the ith i^{\text {th }} rider.

Output

Output kk, the maximum number of riding pairs that can be formed, followed by kk pairs of integers, denoting the numbers of the riders forming each pair. If there are multiple ways to pair off the riders, output any one.

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

2
6 2
3 4