PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BF0000049. Công ty du lịch (Travel Company)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

2 lộ trình

Công ty du lịch (Travel Company)

Travel Company

Source: LightOJ

Version: Phuoc Hung OJ Extended

Problem Statement

A bus company needs a directed cycle with total income divided by total expense strictly greater than PP. Every directed road A→BA\to B has income II and positive expense EE. Determine whether such a cycle exists.

Input

First line N,R,PN,R,P; then RR lines A,B,I,EA,B,I,E. Vertices are zero-based.

Output

Print YES or NO.

Subtasks

  • Subtask 1 (20 points): 2≤N≤102\le N\le10, 0≤R≤250\le R\le25, 1≤P≤1001\le P\le100; 0≤A,B<N0\le A,B<N, A≠BA\ne B, no duplicated directed roads; 0≤I≤50000\le I\le5000; 1≤E≤50001\le E\le5000.
  • Subtask 2 (30 points): 2≤N≤402\le N\le40, 0≤R≤4000\le R\le400, 1≤P≤1001\le P\le100; 0≤A,B<N0\le A,B<N, A≠BA\ne B, no duplicated directed roads; 0≤I≤50000\le I\le5000; 1≤E≤50001\le E\le5000.
  • Subtask 3 (50 points): 2≤N≤1002\le N\le100, 0≤R≤99000\le R\le9900, 1≤P≤1001\le P\le100; 0≤A,B<N0\le A,B<N, A≠BA\ne B, no duplicated directed roads; 0≤I≤50000\le I\le5000; 1≤E≤50001\le E\le5000.

Examples

Input

3 3 2
0 1 5 1
1 2 5 1
2 0 5 1

Output

YES

Explanation

The cycle 0→1→2→00\to1\to2\to0 has total income 1515 and total expense 33. Its ratio is 15/3=5>215/3=5>2, hence YES is correct.