#C10518. Snack Purchase Possibility

    ID: 39732 Type: Default 1000ms 256MiB

Snack Purchase Possibility

Snack Purchase Possibility

You are given n consecutive ranges, where the i-th range is represented as an interval \([l_i, r_i]\). A citizen has exactly m units of money and wishes to purchase a snack. In order to do so, the citizen can optionally choose one number from each range (and it is allowed to skip some ranges) and then sum them up. The goal is to determine whether there exists a selection such that the total sum is exactly m.

Formally, given an integer \(n\) and \(n\) consecutive ranges \([l_i, r_i]\) for \(i=1,2,\ldots,n\), and two integers m and k (where k represents the maximum amount the vending machine may dispense in one transaction, though it is not used in the computation), determine if there exists a subset of ranges and a corresponding choice of an integer from each selected range such that the sum of these integers is exactly \(m\).

If such a selection exists, output YES; otherwise, output NO.

Note: The parameter k is provided but not used in the calculation.

Mathematical formulation:

Find a set of indices \(I \subseteq \{1,2,\ldots,n\}\) and choose an integer \(a_i\) for each \(i \in I\) such that \(l_i \le a_i \le r_i\) and

[ \sum_{i \in I} a_i = m. ]

inputFormat

The first line contains a single integer n (the number of consecutive ranges).

The next n lines each contain two space-separated integers li and ri, representing the endpoints of the i-th range.

The last line contains two space-separated integers m and k, where m is the exact amount of money the citizen has and k is the maximum amount the vending machine will dispense in one transaction.

outputFormat

Output a single line containing YES if the citizen can achieve the exact sum m by selecting at most one integer from any of the provided ranges; otherwise, output NO.

## sample
3
1 3
5 9
12 15
30 5
NO

</p>