p01315 Moonlight Farm
You are enthusiastic about the popular web game "Moonlight Ranch". The purpose of this game is to grow crops in the fields, sell them to earn income, and use that income to grow the ranch.

You wanted to grow the field quickly. Therefore, we decided to arrange the crops that can be grown in the game based on the income efficiency per hour.

You have to buy seeds to grow crops. Here, the name of the species of crop i is given by Li, and the price is given by Pi. When seeds are planted in the field, they sprout after time Ai. Young leaves appear 2 hours after the buds emerge. The leaves grow thick after Ci. The flowers bloom 10 hours after the leaves grow. Fruits come out time Ei after the flowers bloom. One seed produces Fi fruits, each of which sells at the price of Si. Some crops are multi-stage crops and bear a total of Mi fruit. In the case of a single-stage crop, it is represented by Mi = 1. Multi-season crops return to leaves after fruiting until the Mith fruit. The income for a seed is the amount of money sold for all the fruits of that seed minus the price of the seed. In addition, the income efficiency of the seed is the value obtained by dividing the income by the time from planting the seed to the completion of all the fruits.

Your job is to write a program that sorts and outputs crop information given as input, sorted in descending order of income efficiency.



Input

The input is a sequence of datasets, and each dataset is given in the following format.

> N
> L1 P1 A1 B1 C1 D1 E1 F1 S1 M1
> L2 P2 A2 B2 C2 D2 E2 F2 S2 M2
> ...
> LN PN AN BN CN DN EN FN SN MN
>

The first line is the number of crops N in the dataset (1 ≤ N ≤ 50).

The N lines that follow contain information about one crop in each line. The meaning of each variable is as described in the problem statement. The crop name Li is a string of up to 20 characters consisting of only lowercase letters, and 1 ≤ Pi, Ai, Bi, Ci, Di, Ei, Fi, Si ≤ 100, 1 ≤ Mi ≤ 5. It can be assumed that no crop has the same name in one case.

The end of the input is represented by a line containing only one zero.

Output

For each dataset, output the crop names, one for each row, in descending order of income efficiency. For crops with the same income efficiency, output their names in ascending dictionary order.

After the output of each data set, output one line consisting of only "#".

Example

Input

5
apple 1 1 1 1 1 1 1 10 1
banana 1 2 2 2 2 2 1 10 1
carrot 1 2 2 2 2 2 1 10 2
durian 1 3 3 3 3 3 1 10 1
eggplant 1 3 3 3 3 3 1 100 1
4
enoki 1 3 3 3 3 3 1 10 1
tomato 1 3 3 3 3 3 1 10 1
potato 1 3 3 3 3 3 1 10 1
onion 1 3 3 3 3 3 1 10 1
3
a 10 1 1 1 1 1 1 10 1
b 10 2 2 2 2 2 2 10 1
c 10 2 2 2 2 2 2 10 1
0


Output

eggplant
apple
carrot
banana
durian
#
enoki
onion
potato
tomato
#
b
c
a
#
```python
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    while 1:
        n=int(input())
        if n==0:break
        ans=[]
        for _ in range(n):
            l,*num=input().split()
            p,a,b,c,d,e,f,s,m=map(int,num)
            ans.append([(f*s*m-p)/(a+b+c+(d+e)*m),l])
        ans.sort(key=lambda x:(-x[0],x[1]))
        for _,l in ans:
            print(l)
        print("#")

main()


```