#include <bits/stdc++.h>
using namespace std;

int N;
using P = pair<int, int>;
using P3 = pair<P, int>;
vector<P> ul, lr;
vector<int> ans;
int cnt = 0;

void dfs(int bit) { 
  if ( bit == 0 ) return;
  // cout << bit << endl;  
  vector<P3> L;
  for ( int i = 0; i < N; i++ ) {
    if ( (1<<i)&bit ) L.push_back(P3(P(ul[i].first, ul[i].second), i));    
  }
  sort(L.begin(), L.end());
  // ans.push_back(L[0].second);
  ans[L[0].second] = cnt++;  
  int k = L[0].second;
  // cout << "first " << k << " " << ul[k].first << endl;
  for ( P3 &i : L ) i.first.second = i.first.second*(-1);
  sort(L.begin(), L.end());  
  int nxt = 0;  
  for ( int i = 1; i < (int)L.size(); i++ ) {
    int j = L[i].second;
    if ( k == j ) continue;
    // cout << bit << " " << j << " " << L[i].first.second << endl;    
    if ( ul[j].second < lr[k].second &&
	 lr[j].second > lr[k].second ) break;
    if ( lr[k].second >= lr[j].second ) nxt |= (1<<j);    
  }
  dfs(nxt);
  dfs(bit-nxt-(1<<k));   
}

int tests = 0;

int main() {
  while ( cin >> N, N ) {
    cnt = 0;
    ans = vector<int>(N);    
    if ( tests++ ) cout << endl;    
    ul = lr = vector<P>(N);
    ans.clear();    
    for ( int i = 0; i < N; i++ ) {
      cin >> ul[i].first >> ul[i].second;      
      cin >> lr[i].first >> lr[i].second;
    }

    dfs((1<<N)-1);
    for ( int i = 0; i < N; i++ ) cout << ans[i]+1 << endl;
  }
  return 0;  
}

