{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n Arbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar buys 0.5 British pound, 1 British pound buys 10.0 French francs, and 1 French franc buys 0.21 US dollar. Then, by converting currencies, a clever trader can start with 1 US dollar and buy 0.5 * 10.0 * 0.21 \u003d 1.05 US dollars, making a profit of 5 percent. \n \u003cbr\u003e \n \u003cbr\u003eYour job is to write a program that takes a list of currency exchange rates as input and then determines whether arbitrage is possible or not. \n \u003cbr\u003e\n \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n The input will contain one or more test cases. Om the first line of each test case there is an integer n (1\u0026lt;\u003dn\u0026lt;\u003d30), representing the number of different currencies. The next n lines each contain the name of one currency. Within a name no spaces will appear. The next line contains one integer m, representing the length of the table to follow. The last m lines each contain the name ci of a source currency, a real number rij which represents the exchange rate from ci to cj and a name cj of the destination currency. Exchanges which do not appear in the table are impossible. \n \u003cbr\u003eTest cases are separated from each other by a blank line. Input is terminated by a value of zero (0) for n. \n \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n For each test case, print one line telling whether arbitrage is possible or not in the format \"Case case: Yes\" respectively \"Case case: No\". \n \u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e3\nUSDollar\nBritishPound\nFrenchFranc\n3\nUSDollar 0.5 BritishPound\nBritishPound 10.0 FrenchFranc\nFrenchFranc 0.21 USDollar\n\n3\nUSDollar\nBritishPound\nFrenchFranc\n6\nUSDollar 0.5 BritishPound\nUSDollar 4.9 FrenchFranc\nBritishPound 10.0 FrenchFranc\nBritishPound 1.99 USDollar\nFrenchFranc 0.09 BritishPound\nFrenchFranc 0.19 USDollar\n\n0\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003eCase 1: Yes\nCase 2: No\n\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"判断图中是否存在变大环"}}]}