#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

struct Rect {
	int x, y, w, h;
	Rect(int x1, int y1, int x2, int y2) {
		if (x1 > x2) swap(x1, x2);
		if (y1 > y2) swap(y1, y2);
		x = x1, y = y1, w = x2-x1, h = y2-y1;
	}
};

vector<int> read(vector<bool>& used, vector<Rect>& r, vector<bool>& target) {
	int N = used.size();
	vector<int> res;
	while (1) {
		int n = 0; REP(i, N) n += !used[i] && target[i];
		if (n == 0) return res;
//		cout << n << endl;
		int tid = -1;
		{
//			cout << target << endl;
			vector< pair<P,int> > v;
			REP(i, N) {
				if (!used[i] && target[i]) {
					v.pb( pair<P,int>(P(r[i].x, r[i].y), i) );
				}
			}
			tid = min_element(ALL(v))->second;
//			debug(tid);
			used[tid] = true;
			target[tid] = false;
			res.pb(tid);
		}
		int xto = inf;
		REP(i, N) {
//			if (r[i].x+r[i].w <= r[tid].x && r[i].y < r[tid].y+r[tid].h && r[tid].y+r[tid].h < r[i].y+r[i].h) {
			if (r[i].x >= r[tid].x+r[tid].w && r[i].y < r[tid].y+r[tid].h && r[tid].y+r[tid].h < r[i].y+r[i].h) {
				xto = min(xto, r[i].x);
			}
		}
//		debug(xto);
		vector<bool> a(N, false);
		REP(i, N) {
			if (used[i]) continue;
//			if (r[tid].x <= r[i].x && r[i].x+r[i].w <= r[tid].x+r[tid].w && r[i].y+r[i].h <= r[tid].y) {
			if (r[tid].x <= r[i].x && r[i].x+r[i].w <= xto && r[i].y+r[i].h <= r[tid].y+r[tid].h) {
				a[i] = true;
			}
		}
		vector<int> v = read(used, r, a);
		REP(i, v.size()) res.pb(v[i]);
	}
	return res;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	bool isFirst = true;
	int N;
	while (cin >> N, N) {
		if (!isFirst) cout << endl;
		isFirst = false;

		vector<Rect> r;
		REP(i, N) {
			int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
			r.pb( Rect(x1, y1, x2, y2) );
		}
		REP(i, N) {
//			cout << r[i].x << " " << r[i].y << " " << r[i].w << " " << r[i].h << endl;
		}
		vector<bool> used(N, false);
		vector<bool> target(N, true);
		vector<int> ans = read(used, r, target);
		vector<int> ar(N);
		REP(i, N) {
			ar[ans[i]] = i+1;
		}
		REP(i, N) cout << ar[i] << endl;
	}
}