Airline ticket#6305

Airline ticket

1 second
64 megabytes
Hard

An airline is running a unique promotion where it offers passes with the following rules:

Given the pass's value and the costs of all flights, determine if it's possible to plan the flights such that the pass is fully utilized, with no conditional units left over.

Input

The first line contains three natural numbers separated by spaces:

(1 \leq n \leq 1000) – the number of cities served by the airline, (1 \leq m \leq 1000) – the number of flights available, (1 \leq v \leq 1000) – the value of the pass.

Each of the next lines describes the cost of a flight. The first two numbers, v_1 and v_2 (1 \leq v_1, v_2 \leq n), represent the cities connected by the flight, and the third number, (1 \leq w \leq 1000), is the cost of the flight from city v_1 to city v_2 (v_1 and v_2 are different). The numbers are separated by spaces.

It is guaranteed that there is no more than one direct flight between any two cities in each direction.

Output

Print YES if it is possible to plan the flights such that the pass is completely used up, otherwise print NO.

Examples

Example 1

Loading
Loading