As we all know, Alan is the coolest, and thus everyone wants to date him. This makes his decision in who to make his partner difficult. Thus, Alan has decided on an algorithm he will use to determine his partner. There are possible partners for Alan, each with an attractiveness value (of course Alan is not shallow, this includes personality too). He will line them up, and repeat the following process until one person remains:
- Consider the first people in the line:
- Since Alan has standards, he will not date the person with the minimum of the three.
- Since Alan is humble, he will not date the person with the maximum of the three.
- These two people are removed from the line, and the remaining person of the three is sent to the back of the line.
- Ties are broken arbitrarily by Alan's friend Peter, since Alan is indecisive.
of Alan's prospective partners are so excited for the opportunity to date Alan that they have arrived early and chosen a spot in the line. The other however have been stopped by Peter, who has a plan. Peter wants the best for Alan, so he will place the remaining people in the line such that Alan's date ends up with the maximum possible . If Peter places the remaining people optimally, what will be the of Alan's partner?
Input Specification
The first line will contain two integers is odd, and .
The next lines will contain two integers and , representing the attractiveness and the position of the person.
The next lines will contain the integer , representing the attractiveness of one of the people stopped by Peter.
Output Specification
On one line, you are to output the attractiveness of Alan's partner, given Peter places the remaining people optimally.
Subtasks
Subtask 1 (5%)
Subtask 2 (5%)
Subtask 3 (30%)
Subtask 4 (60%)
No further constraints.
Sample Input
7 3
5 2
5 5
8 6
6
2
8
9
Sample Output
8
Comments