Every day, numerous patients visit the doctor. Each patient spends a whole number of minutes during their appointment, but the duration varies from patient to patient. The doctor begins seeing patients at t_1 minutes and concludes at t_2 minutes. This means a patient can enter at any time t_1, t_1 + 1, ..., up to t_2 - 1. Arriving at any other time or during another patient's appointment is not permitted. If a patient arrives at the clinic at time , they wait for the first available moment ≥ when the doctor is free and has already attended to all patients who arrived earlier, i.e., before time . If the doctor cannot see all patients by the end of the session, those remaining must return the following day.
Given the start and end times of the doctor's session, the arrival times of patients on a specific day, and the duration of each patient's examination, determine the optimal time for Petryk Pyatochkin to arrive to ensure he sees the doctor that day with minimal waiting. If multiple times are possible, find the earliest one.
The first line contains three numbers: the number of patients , the session start time t_1, and the session end time t_2, where t_2 is greater than t_1.
The second line provides numbers a_1, a_2, \ldots, a_n - the arrival times of the first, second, ..., -th patient at the clinic. These numbers are distinct and sorted in ascending order.
The third line contains numbers b_1, b_2, \ldots, b_n - the examination durations for the first, second, ..., -th patient.
All input numbers are natural numbers. The number of patients does not exceed 10^5, and the other numbers do not exceed 10^9.
On Petryk Pyatochkin's planet, a day is significantly longer than on Earth, so the start time t_1, end time t_2, as well as the numbers a_1, a_2, \ldots, a_n and b_1, b_2, \ldots, b_n can exceed - the number of minutes in an Earth day.
Output a single natural number - the earliest time Petryk Pyatochkin should arrive at the clinic to ensure he sees the doctor that day with minimal waiting. If Petryk arrives at the same time as another patient, he will be seen first because he is younger.
Example 1
Example 2
Example 3
Example 4