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 m. Follow m triples with two different names of currencies x and y, and the number of y’s given for one x (a real number between 0.6 and 1.5). Assume 2 ≤ m ≤ 1000. There is at most one direct change from x to y for every pair of currencies x and y.
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.
Input
3 euro pound 0.8 pound dollar 1.4 dollar euro 0.9 3 euro pound 0.7 pound dollar 1.4 dollar euro 0.9 3 euro dollar 1.123 yen yuan 1.1 yuan yen 1
Output
YES!!! NO YES!!!