#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cout << 0 << endl;
    cin >> s;
    if(s == "Vacant"){
        return 0;
    }
    int ok = n;
    int ng = 0;
    string tmp;
    while(tmp!="Vacant")
    {
        int mid = (ok + ng) / 2;
        cout << mid << endl;
        cin >> tmp;
        if(mid%2^tmp==s){
            ng = mid;
        }
        else
        {
            ok = mid;
        }
    }
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

int N;
const double EPS = 1e-10;

struct state{
  string name;
  double k;
  state(){}
  state(int P,int A,int B,int C,int D, int E,int F,int S,int M){
    int time = A + B + C + (D + E)*M;
    int num = M * F;
    int mon = num * S;
    int s = mon - P;
    k = (double)s/(double)time;
  }
  bool operator<(const state& st) const {
    return abs(k-st.k) < EPS ? name < st.name : k > st.k;
  }
};

state st[111];
int main(){
  while( cin >> N && N ){
    for(int i=0;i<N;i++){
      string L;int P,A,B,C,D,E,F,S,M;
      cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
      st[i] = state(P,A,B,C,D,E,F,S,M);
      st[i].name = L;
   
    }
    sort(st,st+N);
    for(int i=0;i<N;i++)
      cout << st[i].name << endl;
    cout << "#" << endl;
  }
}