PivotOJ

Bookshelf Building

시간 제한: 2000ms메모리 제한: 512MB출처: GCPC 2020BOJ 20902

문제

Anna just came home from her favourite furniture store Ikey Yeah! where she bought a new bookshelf designed by her favourite artist Bill Lee. The shelf has a rectangular shape with a width of xx and a height of yy. Included in the box of the shelf is one board that Anna may put horizontally inside the shelf. For this purpose the frame of the shelf already contains pre-drilled holes at heights 1,2,,y11,2,\ldots,y-1. Anna may attach the board to the frame at any of these heights. She can also decide not to install it at all.

Anna owns nn books, which all have the same depth. The books' depth matches that of the shelf exactly. However, due to differences in the formats and the numbers of pages, her books may have different widths and heights. Anna does not want to flip her books or stack several of them on top of each other. Instead, she wants to store all of them in an upright fashion inside her bookshelf, such that the width and height of each book are aligned with the width and height of the bookshelf. Help Anna to find the perfect position for the board (or tell her not to use it at all) so that she can store all her books in her new bookshelf.

For this problem you may assume that the frame and the board of the shelf are infinitely thin.

입력

The input consists of:

  • One line with three integers nn, xx and yy, where 
    • nn (1n1041 \le n \le 10^4) is the number of books that Anna owns;
    • xx (1x1041 \le x \le 10^4) is the width of the bookshelf frame;
    • yy (1y1041 \le y \le 10^4) is the height of the bookshelf frame.
  • nn lines, the iith of which contains two integers wiw_i and hih_i, where
    • wiw_i (1wi1041 \le w_i \le 10^4) is the width of the iith book;
    • hih_i (1hi1041 \le h_i \le 10^4) is the height of the iith book.

출력

If there is no possibility to store Anna's books in the shelf, print out impossible. In case Anna decides not to install the board, output 1-1. Otherwise, output the height at which the board should be installed. If there are multiple possible heights, you may output any one of them.

예제

예제 1

입력
4 4 4
3 1
1 1
1 3
2 2
출력
3

예제 2

입력
2 4 3
2 3
1 1
출력
-1

예제 3

입력
3 3 3
2 2
2 1
2 1
출력
impossible
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.