This page is still under construction.

Parts of this page are still being built. What you see may change.

Escape from Hell

Time limit2sMemory limit512 MB

Summary
Choose an order to use N energy drinks so the climber reaches length L on the earliest day without sinners catching up at night.
Level

Hard8 of 10

Topics
Greedy, Sorting, Implementation, Binary search
Solved
No attempts yet

Problem

One day, Buddha looked down into hell and noticed an office worker. The man had done evil, such as forcing unreasonable workloads on his subordinates, but he had done exactly one good deed in his life: he refused an unfair demand from a customer in order to protect his subordinates' lives. Buddha decided that this deed earned him a chance to escape, and lowered a single strand of spider silk into hell.

The office worker started to climb the silk, but the way out is LL meters long, far too long for one day. He has NN energy drinks and drinks one of them each day. On the day he drinks the ii-th drink, he climbs AiA_i meters during the daytime and then slides down BiB_i meters during the night. If his height reaches LL meters or more during the daytime, he escapes at once without sliding down. After NN days the silk is cut.

He then noticed that other sinners climb the silk every night. During the ii-th night the sinners climb CiC_i meters, and they never slide down during the day. If the sinners catch up with the office worker, a fight breaks out and the silk is cut. That is, if the sinners' height is greater than or equal to the office worker's height at the end of any night, he can no longer escape. The office worker and the sinners all start at height 0.

Write a program that chooses the best order in which to drink the energy drinks and prints the earliest day on which the office worker can escape. If he cannot escape, print -1.

Input

The input consists of a single test case.

N L
A1 B1
...
AN BN
C1
...
CN

The first line contains two integers NN (1≤N≤1051 \le N \le 10^5) and LL (1≤L≤1091 \le L \le 10^9), the number of energy drinks and the length of the spider silk. Among the next NN lines, the ii-th line contains two integers AiA_i (1≤Ai≤1091 \le A_i \le 10^9) and BiB_i (1≤Bi≤1091 \le B_i \le 10^9) describing the ii-th energy drink: on the day he drinks it, the office worker climbs AiA_i meters in the daytime and slides down BiB_i meters at night. Among the following NN lines, the ii-th line contains an integer CiC_i (1≤Ci≤1091 \le C_i \le 10^9), the distance the other sinners climb during the ii-th night.

Output

Print the earliest day on which the office worker can escape. If he cannot escape, print -1.

Examples4

  1. Example 1

    Input
    3 9
    6 3
    5 2
    3 1
    2
    2
    2
    
    Expected output
    2
    
  2. Example 2

    Input
    5 20
    3 2
    4 2
    6 3
    8 4
    10 5
    4
    2
    3
    4
    5
    
    Expected output
    -1
    
  3. Example 3

    Input
    5 20
    6 5
    7 3
    10 3
    10 14
    4 7
    2
    5
    3
    9
    2
    
    Expected output
    3
    
  4. Example 4

    Input
    4 12
    8 4
    6 4
    2 1
    2 1
    1
    1
    4
    4
    
    Expected output
    -1