#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#define MAX 50
using namespace std;

typedef struct {
  string name;
  double rate;
}hurvest;

bool cmp(const hurvest &a,const hurvest &b){
  return a.rate > b.rate;
}

int main(){
  array<hurvest,MAX> data;
  int n,seed_cost,time_sum,time,value,F,S,M,D,E;

  while(1){
  cin >> n;
  if(n==0){
    break;
  }
  for(int i=0;i<n;i++){
    cin >> data[i].name>>seed_cost;
    time_sum=0;
    for(int j=0;j<5;j++){
      cin >> time;
      if(j==3){
	D=time;
      }
      if(j==4){
	E=time;
      }
      time_sum+=time;
    }
    
    cin >> F >> S >> M;
    value=F*S;
    if(M!=1){
      value*=M;
      time_sum+=(E+D)*(M-1);
    }
    data[i].rate=(double)(value-seed_cost)/(double)time_sum;
  }

  sort(data.begin(),data.end()-(50-n),cmp);

  bool change=true;
  hurvest temp;
  while(change){
    change=false;
    for(int i=0;i<n-1;i++){
      if(data[i].rate==data[i+1].rate){
	if(data[i].name>data[i+1].name){
	  temp=data[i];
	  data[i]=data[i+1];
	  data[i+1]=temp;
	  change=true;
	}
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << data[i].name<<endl;
  }
  cout << '#' <<endl;
  }


  return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

typedef pair<double,string> PDS;

bool my_greater(PDS a, PDS b){
  if(a.first==b.first){
    return (a.second > b.second);
  }else{
    return a.first < b.first;
  }
}

void solve(int n){
  vector<PDS> vp(n);

  string L;
  double P,A,B,C,D,E,F,S,M;
  for(int i=0;i<n;i++){
    cin>>L>>P>>A>>B>>C>>D>>E>>F>>S>>M;
    double res=(F*S*M-P)/(A+B+C+(D+E)*M);
    vp[i]=mp(res,L);
  }

  sort(all(vp),my_greater);
  reverse(all(vp));
  for(int i=0;i<n;i++){
    cout<<vp[i].second<<endl;
  }
}

int main(){
  int n;
  while(cin>>n,n){
    solve(n);
    cout<<"#"<<endl;
  }
  return 0;
}

