F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Hero

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 467    Accepted Submission(s): 8


Problem Description
Every one own herself hero. The different hero must be famous in different field. So to compare them is a difficult things. Now given every hero a integer value to express the degree of famous. We call it Fv.
yifenfei want to know who is the most famous hero, so he ask many people to get the answer. Lots of people tell him as that: the Fv of hero A / the Fv of hero B equal to p / q.
 

Input
There are multiple cases in the input file.
Each case contains n (0< n <=27)
Next follow n line, each line as (hero A name # hero B name, p , q ).Length of name less 100 (the name will no ¡±#¡±). p, q is A positive integer less 10.
 

Output
Out put every hero relative value, the answer should be smallest(order by the lexicographically of hero name). Out put a line after every case. You may sure every case has answer.
 

Sample Input
1 Zhao yun # ji yuan 4 6 2 Ji yuan # Lemon 3 5 Lemon # Qi shi wang 2 9
 

Sample Output
Zhao yun 2 ji yuan 3 Ji yuan 6 Lemon 10 Qi shi wang 45
 

Author
yifenfei
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-25 20:54:24, Gzip enabled