#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <string>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int x1[10],y1[10],x2[10],y2[10];
int order[10];
bool readf[10];
int cnt;
int n;

typedef pair<int,int> pii;
typedef pair<pair<int,int> ,int> piii;

void rec(set<int> se) {
  while(1) {
    set<piii> vvv;
    FOR(it,se) {                  // ツ暗ェツ氾板右ツ湘」ツづ個右ツ湘」ツづーツ探ツつキ
//      cout << *it << "";
      if (!readf[*it])
        vvv.insert(piii(pii(x1[*it],y1[*it]),*it));
//      cout <<"("<< x1[*it]<< " " <<y1[*it]<<") ";
    }
    if (vvv.size() == 0) break;
//    cout << endl;
    int now = min_element(ALL(vvv))->second;
//    cout << now << endl;
    readf[now] = 1;
    order[now] = cnt++;
    int mi = INF;
    REP(i,n) {
      if (x1[i] >= x1[now] && y1[i] < y2[now] && y2[now] < y2[i]) {
        mi = min(mi,x1[i]);
      }
    }
    set<int> next;
    REP(i,n) {
      if (!readf[i] && y2[i] <= y2[now] && mi >= x2[i] && x1[i] >= x1[now]) {
        next.insert(i);
      }
    }
    if (next.size())
      rec(next);
  }
}

int main() {
  int nnnn = 0;
  while(cin >> n, n) {
    if (nnnn)
      cout << endl;
    else
      nnnn = 1;
    REP(i,n) {
      int x,y,xx,yy;
      cin >>x>>y>>xx>>yy;
      x1[i] = min(x,xx);
      x2[i] = max(x,xx);
      y1[i] = min(y,yy);
      y2[i] = max(y,yy);
    }
    memset(readf,0,sizeof(readf));
    cnt = 0;
    set<int> se;
    REP(i,n) se.insert(i);
    rec(se);
    REP(i,n) {
      cout << order[i]+1 << endl;
    }
  }
}