Absenteeism

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

Absenteeism is a habitual pattern of absence from a duty or obligation without good reason.

Wikipedia

Alex works at work. nn employees work together with him. Unlike Alex, they strictly follow their schedule: the ii-th employee comes to work at the time moment a_ia\_i and leaves at the time moment b_ib\_i (a_i<b_ia\_i < b\_i).

Alex has to come to work not earlier the time moment 0, leave not later the time moment mm and work for kk hours a day (kmk \le m). But, of course, he wants to work as less as possible. The problem is, his colleagues don't like lazy people, and if one of them discovers that Alex works less than kk hours a day, they complain to the boss and Alex will be fired.

In other words, let's say Alex comes to work at the time moment xx and leaves work at the time moment yy, where 0x<ym0 \le x < y \le m. Then Alex is in danger if at least one of the following conditions is satisfied:

  • yx<ky - x < k, and there exists an employee ii such that a_ixa\_i \le x and yb_iy \le b\_i (the segment \[x,y]\[x, y] is entirely nested into \[a_i,b_i]\[a\_i, b\_i]) --- in this case the ii-th employee sees how Alex works less than kk hours with their own eyes;
  • there exists an employee ii such that x<a_iyb_ix < a\_i \le y \le b\_i, and y<ky < k --- in this case the ii-th employee sees how Alex leaves work earlier than the time moment kk;
  • there exists an employee ii such that a_ixb_i<ya\_i \le x \le b\_i < y, and x>mkx > m - k --- in this case the ii-th employee sees how Alex comes to work later than the time moment mkm - k;
  • there exists an employee ii such that y<a_iy < a\_i or b_i<xb\_i < x (the segments \[x,y]\[x, y] and \[a_i,b_i]\[a\_i, b\_i] don't intersect), and a_ika\_i \le k and b_imkb\_i \ge m - k --- in this case the ii-th employee doesn't see Alex at work at all, but it's exactly the reason they conclude Alex couldn't work for kk hours.

What is the minimal time Alex can spend at work such that nobody of his colleagues complains to the boss?

입력

The first line contains three integers nn, mm, kk (1n1051 \le n \le 10^5, 1m1091 \le m \le 10^9, 1km1 \le k \le m) --- the number of employees working together with Alex, the day length and the number of hours Alex has to work in a day.

Each of the following nn lines contains two integers a_ia\_i and b_ib\_i (0a_i<b_im0 \le a\_i < b\_i \le m) --- the moments of time when the ii-th employee comes to work and leaves work.

출력

If Alex is able to not come to work at all, output "-1 -1".

Otherwise, output two integers xx, yy (0x<ym0 \le x < y \le m, yxky - x \le k) --- the moments of time when Alex should come to work and leave work, so that nobody of his colleagues complain to the boss and the working time is minimal.

If there are several possible solutions, output any of them.