Currency converter

You are using an on-line currency converter because you are curious about several changes. You notice that they give you 0.8 pounds for one euro, 1.4 dollars for one pound, and 0.9 euros for one dollar. Mmm... what? Wait a moment... So they really give you 1.008 euros for one euro??? Hurry up, you can get rich!

Input

Input consists of several cases. Every case begins with the number of direct changes mm. Follow mm triples with two different names of currencies xx and yy, and the number of yy’s given for one xx (a real number between 0.6 and 1.5). Assume 2m10002 \le m \le 1000. There is at most one direct change from xx to yy for every pair of currencies xx and yy.

Output

For every case, print “YES!!!” if you can get rich, and print “NO” otherwise. Assume that, initially, you have a small amount of every currency. The input cases have no precision issues.

Problem information

Author: Enric Rodríguez

Generation: 2026-01-25T12:01:10.258Z

© Jutge.org, 2006–2026.
https://jutge.org