#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
struct comp{
bool operator()(int a, int b){
return a>b;
}
};
///________CODE_STARTS_HERE________\\\
struct rekt{
int x1,y1,x2,y2,pos;
} a[500005],b[500005];
vector <int> g[500005];
bool cx1(rekt a, rekt b){
if(a.x1<b.x1) return true;
else if(a.x1>b.x1) return false;
else if(a.y2<=b.y2) return true;
else return false;
}
bool cx2(rekt a, rekt b){
if(a.x2<b.x2) return true;
else if(a.x2>b.x2) return false;
else if(a.y1<=b.y1) return true;
else return false;
}
bool cy1(rekt a, rekt b){
if(a.y1<b.y1) return true;
else if(a.y1>b.y1) return false;
else if(a.x2<=b.x1) return true;
else return false;
}
bool cy2(rekt a, rekt b){
if(a.y2<b.y2) return true;
else if(a.y2>b.y2) return false;
else if(a.x1<=b.x1) return true;
else return false;
}
int n,col[500005],can[5],v[500005];
void DFS(int nod){
if(v[nod]) return;
v[nod]=1;
bool can[5];
for(int i : g[nod]){
DFS(i);
can[col[i]]=1;
}
for(int i=1;i<=4;i++){
if(!can[i]) {
col[nod]=i;
break;
}
}
}
int main(){
ios_base :: sync_with_stdio(0); cin.tie(NULL);
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;
a[i].pos=i;
}
for(int i=1;i<=n;i++){
if(a[i].x1>a[i].x2){
swap(a[i].x1,a[i].x2);
}
if(a[i].y1>a[i].y2){
swap(a[i].y1,a[i].y2);
}
b[i]=a[i];
}
sort(a+1,a+n+1,cx1);
sort(b+1,b+n+1,cx2);
int p=1;
for(int i=1;i<=n;i++){
while(a[p].x1<b[i].x2 && p<=n) p++;
if(p>n || a[p].x1>b[i].x2) continue;
while(a[p].y2<=b[i].y1 && p<=n && a[p+1].x1==b[i].x2) p++;
if(p>n) continue;
while(a[p].y2>b[i].y1 && a[p].y1<b[i].y2 && p<=n && a[p].x1==b[i].x2){
g[b[i].pos].push_back(a[p].pos);
g[a[p].pos].push_back(b[i].pos);
p++;
}
p--;
}
sort(a+1,a+n+1,cy1);
sort(b+1,b+n+1,cy2);
p=1;
for(int i=1;i<=n;i++){
while(a[p].y1<b[i].y2 && p<=n) p++;
if(p>n || a[p].y1>b[i].y2) continue;
while(a[p].x2<=b[i].x1 && p<=n && a[p+1].y1==b[i].y2) p++;
if(p>n) continue;
while(a[p].x2>b[i].x1 && a[p].x1<b[i].x2 && p<=n && a[p].y1==b[i].y2){
g[b[i].pos].push_back(a[p].pos);
g[a[p].pos].push_back(b[i].pos);
p++;
}
p--;
}
/*for(int i=1;i<=n;i++){
cout << i << ": ";
for(int j : g[i]){
cout << j << ' ';
}
cout << '\n';
}*/
for(int i=1;i<=n;i++){
DFS(i);
if(!col[i]){
cout << "NO";
return 0;
}
}
cout << "YES\n";
for(int i=1;i<=n;i++){
cout << col[i] << '\n';
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgeCBmaXJzdAojZGVmaW5lIHkgc2Vjb25kCiNkZWZpbmUgZGJnKHgpIGNvdXQgPDwgI3ggPDwgJz0nIDw8IHggPDwgJ1xuJzsKI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBwaSBwYWlyPGludCxpbnQ+CiNkZWZpbmUgcGwgcGFpcjxsb25nIGxvbmcsbG9uZyBsb25nPgojZGVmaW5lIHJkKHgpIGNpbiA+PiB4OwojZGVmaW5lIHJkYShhLG4pIGZvcihpbnQgaT0xO2k8PW47aSs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KHJla3QgYSwgcmVrdCBiKXsKICAgIGlmKGEueTE8Yi55MSkgcmV0dXJuIHRydWU7CiAgICBlbHNlIGlmKGEueTE+Yi55MSkgcmV0dXJuIGZhbHNlOwogICAgZWxzZSBpZihhLngyPD1iLngxKSByZXR1cm4gdHJ1ZTsKICAgIGVsc2UgcmV0dXJuIGZhbHNlOwp9Cgpib29sIGN5MihyZWt0IGEsIHJla3QgYil7CiAgICBpZihhLnkyPGIueTIpIHJldHVybiB0cnVlOwogICAgZWxzZSBpZihhLnkyPmIueTIpIHJldHVybiBmYWxzZTsKICAgIGVsc2UgaWYoYS54MTw9Yi54MSkgcmV0dXJuIHRydWU7CiAgICBlbHNlIHJldHVybiBmYWxzZTsKfQoKaW50IG4sY29sWzUwMDAwNV0sY2FuWzVdLHZbNTAwMDA1XTsKCnZvaWQgREZTKGludCBub2QpewogICAgaWYodltub2RdKSByZXR1cm47CiAgICB2W25vZF09MTsKICAgIGJvb2wgY2FuWzVdOwogICAgZm9yKGludCBpIDogZ1tub2RdKXsKICAgICAgICBERlMoaSk7CiAgICAgICAgY2FuW2NvbFtpXV09MTsKICAgIH0KICAgIGZvcihpbnQgaT0xO2k8PTQ7aSsrKXsKICAgICAgICBpZighY2FuW2ldKSB7CiAgICAgICAgICAgIGNvbFtub2RdPWk7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIH0KICAgIH0KfQoKaW50IG1haW4oKXsKICAgIGlvc19iYXNlIDo6IHN5bmNfd2l0aF9zdGRpbygwKTsgY2luLnRpZShOVUxMKTsKICAgIGNpbiA+PiBuOwogICAgZm9yKGludCBpPTE7aTw9bjtpKyspewogICAgICAgIGNpbiA+PiBhW2ldLngxID4+IGFbaV0ueTEgPj4gYVtpXS54MiA+PiBhW2ldLnkyOwogICAgICAgIGFbaV0ucG9zPWk7CiAgICB9CiAgICBmb3IoaW50IGk9MTtpPD1uO2krKyl7CiAgICAgICAgaWYoYVtpXS54MT5hW2ldLngyKXsKICAgICAgICAgICAgc3dhcChhW2ldLngxLGFbaV0ueDIpOwogICAgICAgIH0KICAgICAgICBpZihhW2ldLnkxPmFbaV0ueTIpewogICAgICAgICAgICBzd2FwKGFbaV0ueTEsYVtpXS55Mik7CiAgICAgICAgfQogICAgICAgIGJbaV09YVtpXTsKICAgIH0KICAgIHNvcnQoYSsxLGErbisxLGN4MSk7CiAgICBzb3J0KGIrMSxiK24rMSxjeDIpOwogICAgaW50IHA9MTsKICAgIGZvcihpbnQgaT0xO2k8PW47aSsrKXsKICAgICAgICB3aGlsZShhW3BdLngxPGJbaV0ueDIgJiYgcDw9bikgcCsrOwogICAgICAgIGlmKHA+biB8fCBhW3BdLngxPmJbaV0ueDIpIGNvbnRpbnVlOwogICAgICAgIHdoaWxlKGFbcF0ueTI8PWJbaV0ueTEgJiYgcDw9biAmJiBhW3ArMV0ueDE9PWJbaV0ueDIpIHArKzsKICAgICAgICBpZihwPm4pIGNvbnRpbnVlOwogICAgICAgIHdoaWxlKGFbcF0ueTI+YltpXS55MSAmJiBhW3BdLnkxPGJbaV0ueTIgJiYgcDw9biAmJiBhW3BdLngxPT1iW2ldLngyKXsKICAgICAgICAgICAgZ1tiW2ldLnBvc10ucHVzaF9iYWNrKGFbcF0ucG9zKTsKICAgICAgICAgICAgZ1thW3BdLnBvc10ucHVzaF9iYWNrKGJbaV0ucG9zKTsKICAgICAgICAgICAgcCsrOwogICAgICAgIH0KICAgICAgICBwLS07CiAgICB9CiAgICBzb3J0KGErMSxhK24rMSxjeTEpOwogICAgc29ydChiKzEsYituKzEsY3kyKTsKICAgIHA9MTsKICAgIGZvcihpbnQgaT0xO2k8PW47aSsrKXsKICAgICAgICB3aGlsZShhW3BdLnkxPGJbaV0ueTIgJiYgcDw9bikgcCsrOwogICAgICAgIGlmKHA+biB8fCBhW3BdLnkxPmJbaV0ueTIpIGNvbnRpbnVlOwogICAgICAgIHdoaWxlKGFbcF0ueDI8PWJbaV0ueDEgJiYgcDw9biAmJiBhW3ArMV0ueTE9PWJbaV0ueTIpIHArKzsKICAgICAgICBpZihwPm4pIGNvbnRpbnVlOwogICAgICAgIHdoaWxlKGFbcF0ueDI+YltpXS54MSAmJiBhW3BdLngxPGJbaV0ueDIgJiYgcDw9biAmJiBhW3BdLnkxPT1iW2ldLnkyKXsKICAgICAgICAgICAgZ1tiW2ldLnBvc10ucHVzaF9iYWNrKGFbcF0ucG9zKTsKICAgICAgICAgICAgZ1thW3BdLnBvc10ucHVzaF9iYWNrKGJbaV0ucG9zKTsKICAgICAgICAgICAgcCsrOwogICAgICAgIH0KICAgICAgICBwLS07CiAgICB9CiAgICAvKmZvcihpbnQgaT0xO2k8PW47aSsrKXsKICAgICAgICBjb3V0IDw8IGkgPDwgIjogIjsKICAgICAgICBmb3IoaW50IGogOiBnW2ldKXsKICAgICAgICAgICAgY291dCA8PCBqIDw8ICcgJzsKICAgICAgICB9CiAgICBjb3V0IDw8ICdcbic7CiAgICB9Ki8KICAgIGZvcihpbnQgaT0xO2k8PW47aSsrKXsKICAgICAgICBERlMoaSk7CiAgICAgICAgaWYoIWNvbFtpXSl7CiAgICAgICAgICAgIGNvdXQgPDwgIk5PIjsKICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCAiWUVTXG4iOwogICAgZm9yKGludCBpPTE7aTw9bjtpKyspewogICAgICAgIGNvdXQgPDwgY29sW2ldIDw8ICdcbic7CiAgICB9Cn0K