#include<bits/stdc++.h>

#define inf 0x3f3f3f3f

const int maxn=;

using namespace std;

int n;

struct rook{
int x1,y1;
int x2,y2;
int id;
int resx,resy;
int size(){
return abs(x1 - x2) * abs(x1 - x2) + abs(y1 - y2) * abs(y1 - y2);
}
int width(){
return abs(x1 - x2);
}
int len(){
return abs(y1 - y2);
}
}rooks[maxn+]; int flagx[maxn+]; int flagy[maxn+]; bool cmpx(rook a, rook b){
/*if(a.width() == b.width()){
return a.x1 < b.x1;
}
return a.width() < b.width();*/
//刚开始想错了,这么去贪心,是错的。
/* 反例
* 1111
* 1
* 1
* 1
* 11
*/
if(a.x2 == b.x2){
return a.x1 < b.x1;
}
return a.x2 < b.x2;
}
bool cmpy(rook a, rook b){
/*if(a.len() == b.len()){
return a.y1 < b.y1;
}
return a.len() < b.len();*/
if(a.y2 == b.y2){
return a.y1 < b.y1;
}
return a.y2 < b.y2;
}
bool cmp1(rook a, rook b){
return a.id < b.id;
} int main()
{
while(scanf("%d",&n)!=EOF&&n){
int res = ;
memset(flagx, , sizeof(flagx));
memset(flagy, , sizeof(flagy));
for(int i = ; i < n; ++i){
scanf("%d%d%d%d",&rooks[i].x1,&rooks[i].y1,&rooks[i].x2,&rooks[i].y2);
rooks[i].id = i;
}
sort(rooks, rooks + n, cmpx);
for(int i = ; i < n; ++i){
int flag = ;
for(int j = rooks[i].x1; j <= rooks[i].x2; ++j){
if(!flagx[j]){
flagx[j] = ;
rooks[i].resx = j;
flag = ;
break;
}
}
if(!flag){
res = ;
break;
}
}
if(!res){
sort(rooks, rooks + n, cmpy);
for(int i = ; i < n; ++i){
int flag = ;
for(int j = rooks[i].y1; j <= rooks[i].y2; ++j){
if(!flagy[j]){
flagy[j] = ;
rooks[i].resy = j;
flag = ;
break;
}
}
if(!flag){
res = ;
break;
}
}
}
if(res){
printf("IMPOSSIBLE\n");
} else {
sort(rooks, rooks + n, cmp1);
for(int i = ; i < n; ++i){
printf("%d %d\n",rooks[i].resx,rooks[i].resy);
}
}
}
return ;
}
05-11 13:51