#include<map>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int c[9];
int ct;
void fn(map<pair<pair<int,int>,pair<int,int> >,int> a){
  while(a.empty()==0){
    c[(*a.begin()).second]=ct;
    ct++;
    int y=(*a.begin()).first.second.second;
    unsigned x=-1;
    map<pair<pair<int,int>,pair<int,int> >,int>::iterator it;
    for(it=a.begin();it!=a.end();it++){
      if((*it).first.first.second<y&&(*it).first.second.second>y)
	x=min(x,(unsigned)(*it).first.first.first);
    }    
    a.erase(a.begin());
    map<pair<pair<int,int>,pair<int,int> >,int> b;
    for(it=a.begin();it!=a.end();it++){
      if((unsigned)(*it).first.second.first<=x&&(*it).first.second.second<=y){
	b[(*it).first]=(*it).second;
	a.erase(it);
      }
    }
    fn(b);
  }
  return;
}
int main(){
  int h=0,i;
  int n;
  while(cin>>n&&n){
    if(h)
      cout<<endl;
    else
      h=1;
    map<pair<pair<int,int>,pair<int,int> >,int> a;
    for(i=0;i<n;i++){
      int p,q,r,s;
      cin>>p>>q>>r>>s;
      a[make_pair(make_pair(p,q),make_pair(r,s))]=i;
    }
    ct=1;
    fn(a);
    for(i=0;i<n;i++)
      cout<<c[i]<<endl;
  }
  return 0;
}