
ZOJ Problem Set  1544
Several currency exchange points are working in our city. Let us suppose that
each point specializes in two particular currencies and performs exchange operations
only with these currencies. There can be several points specializing in the
same pair of currencies. Each point has its own exchange rates, exchange rate
of A to B is the quantity of B you get for 1A. Also each exchange point has
some commission, the sum you have to pay for your exchange operation. Commission
is always collected in source currency. You surely know that there are N different currencies you can deal with in
our city. Let us assign unique integer number from 1 to N to each currency.
Then each exchange point can be described with 6 numbers: integer A and B 
numbers of currencies it exchanges, and real RAB, CAB, RBA and CBA  exchange
rates and commissions when exchanging A to B and B to A respectively.
The first line of the input file contains four numbers: N  the number of currencies,
M  the number of exchange points, S  the number of currency Nick has and V
 the quantity of currency units he has. The following M lines contain 6 numbers
each  the description of the corresponding exchange point  in specified above
order. Numbers are separated by one or more spaces. 1 <= S <= N <=
100, 1 <= M <= 100, V is real number, 0 <= V <= 10^3. Process to the end of file.
If Nick can increase his wealth, output YES, in other case output NO to the output file.
3 2 1 10.0
NO Source: Northeastern Europe 2001, Northern Subregion 