#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 500005
#define ll long long
#define p(t) cout<<t;
#define f(i,n) for(i=0;i<n;i++)
#define g(i,n) for(i=1;i<=n;i++)
#define s(x) scanf("%I64d",&x);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll m,n,r,u,xc,yc,a[N],b[N],c[N];
pair<pair<ll,ll> ,pair<ll,ll> > p[N];
map<pair<pair<ll,ll> ,pair<ll,ll> > ,ll> in;
vector<ll> v[N];
void dfs(ll x){
    if(c[x]==1 || r==-1)return;
    c[x]=1;
    ll i,j,k,l;
    ll co[]= {0,0,0,0,0};
    for(i=0;i<v[x].size();i++){
        j=v[x][i];
        dfs(j);
        l=a[j];
        co[l]++;
    }
    g(i,4)if(co[i]==0){a[x]=i; break;}
    if(i==5)r=-1;

}

int main()
{
ios_base::sync_with_stdio(0);
ll k=0,x,sum=1,q=0,z=0,y=0,l=0,i,t,j;
cin>>n;
f(i,n){
    cin>>p[i].ff.ff>>p[i].ff.ss>>p[i].ss.ff>>p[i].ss.ss;
    in[mp(mp(p[i].ff.ff,p[i].ff.ss),mp(p[i].ss.ff,p[i].ss.ss) )]=i+1;
}
sort(p,p+n);
f(i,n){
    for(j=i+1;j<n;j++){
        if(p[j].ff.ff>p[i].ss.ff)break;
          if(p[i].ss.ff == p[j].ff.ff && p[i].ss.ss==p[j].ff.ss)break;
          if(p[i].ss.ff == p[j].ff.ss && p[i].ff.ss==p[j].ss.ss)continue;
        if((p[j].ff.ss >=p[i].ff.ss && p[j].ff.ss <= p[i].ss.ss) || (p[j].ss.ss >=p[i].ff.ss && p[j].ss.ss <= p[i].ss.ss)){
          v[i].pb(j); v[j].pb(i);
        } else if ((p[i].ff.ss >=p[j].ff.ss && p[i].ff.ss <= p[j].ss.ss) || (p[i].ss.ss >=p[j].ff.ss && p[j].ss.ss >= p[i].ss.ss)){
            v[i].pb(j); v[j].pb(i);
        }
    }
}
f(i,n){if(c[i]==0)dfs(i);}
if(r==-1)cout<<"NO";
else {
    cout<<"YES\n";
    f(i,n){
        t=a[i];
        l =in[mp(mp(p[i].ff.ff,p[i].ff.ss),mp(p[i].ss.ff,p[i].ss.ss) )];
        b[l]=t;
        //cout<<l<<" "<<t;
    }
    g(i,n){
        cout<<b[i]<<endl;
    }
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 500005
#define ll long long
#define p(t) cout<<t;
#define f(i,n) for(i=0;i<n;i++)
#define g(i,n) for(i=1;i<=n;i++)
#define s(x) scanf("%I64d",&x);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll m,n,r,u,xc,yc,a[N],b[N],c[N];

int main()
{
ios_base::sync_with_stdio(0);
ll k=0,x,sum=1,q=0,z=0,y=0,l=0,i,t,j;
cin>>n;
cout<<"YES\n";
f(i,n){
    cin>>x>>y>>j>>k;
    cout<<(1+(x&1)+2*(y&1))<<endl;
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 500005
#define ll long long
#define p(t) cout<<t;
#define f(i,n) for(i=0;i<n;i++)
#define g(i,n) for(i=1;i<=n;i++)
#define s(x) scanf("%I64d",&x);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll m,n,r,u,xc,yc,a[N],b[N],c[N];
pair<pair<ll,ll> ,pair<ll,ll> > p[N];
map<pair<pair<ll,ll> ,pair<ll,ll> > ,ll> in;
vector<ll> v[N];
void dfs(ll x){
    if(c[x]==1 || r==-1)return;
    c[x]=1;
    ll i,j,k,l;
    ll co[]= {0,0,0,0,0};
    for(i=0;i<v[x].size();i++){
        j=v[x][i];
        dfs(j);
        l=a[j];
        co[l]++;
    }
    g(i,4)if(co[i]==0){a[x]=i; break;}
    if(i==5)r=-1;

}

int main()
{
ios_base::sync_with_stdio(0);
ll k=0,x,sum=1,q=0,z=0,y=0,l=0,i,t,j;
cin>>n;
f(i,n){
    cin>>p[i].ff.ff>>p[i].ff.ss>>p[i].ss.ff>>p[i].ss.ss;
    in[mp(mp(p[i].ff.ff,p[i].ff.ss),mp(p[i].ss.ff,p[i].ss.ss) )]=i+1;
}
sort(p,p+n);
f(i,n){
    for(j=i+1;j<n;j++){
        if(p[j].ff.ff>p[i].ss.ff)break;
          if(p[i].ss.ff == p[j].ff.ff && p[i].ss.ss==p[j].ff.ss)break;
          if(p[i].ss.ff == p[j].ff.ff && p[i].ff.ss==p[j].ss.ss)continue;
        if((p[j].ff.ss >=p[i].ff.ss && p[j].ff.ss <= p[i].ss.ss) || (p[j].ss.ss >=p[i].ff.ss && p[j].ss.ss <= p[i].ss.ss)){
          v[i].pb(j); v[j].pb(i);
        } else if ((p[i].ff.ss >=p[j].ff.ss && p[i].ff.ss <= p[j].ss.ss) || (p[i].ss.ss >=p[j].ff.ss && p[j].ss.ss >= p[i].ss.ss)){
            v[i].pb(j); v[j].pb(i);
        }
    }
}
f(i,n){if(c[i]==0)dfs(i);}
if(r==-1)cout<<"NO";
else {
    cout<<"YES\n";
    f(i,n){
        t=a[i];
        l =in[mp(mp(p[i].ff.ff,p[i].ff.ss),mp(p[i].ss.ff,p[i].ss.ss) )];
        b[l]=t;
        //cout<<l<<" "<<t;
    }
    g(i,n){
        cout<<b[i]<<endl;
    }
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 500005
#define ll long long
#define p(t) cout<<t;
#define f(i,n) for(i=0;i<n;i++)
#define g(i,n) for(i=1;i<=n;i++)
#define s(x) scanf("%I64d",&x);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll m,n,r,u,xc,yc,a[N],b[N],c[N];

int main()
{
ios_base::sync_with_stdio(0);
ll k=0,x,sum=1,q=0,z=0,y=0,l=0,i,t,j;
cin>>n;
f(i,n){
    cin>>x>>y>>j>>k;
    cout<<(1+(x&1)+2*(y&1))<<endl;
}

return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 500005
#define ll long long
#define p(t) cout<<t;
#define f(i,n) for(i=0;i<n;i++)
#define g(i,n) for(i=1;i<=n;i++)
#define s(x) scanf("%I64d",&x);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll m,n,r,u,xc,yc,a[N],b[N],c[N];
pair<pair<ll,ll> ,pair<ll,ll> > p[N];
map<pair<pair<ll,ll> ,pair<ll,ll> > ,ll> in;
vector<ll> v[N];
void dfs(ll x){
    if(c[x]==1 || r==-1)return;
    c[x]=1;
    ll i,j,k,l;
    ll co[]= {0,0,0,0,0};
    for(i=0;i<v[x].size();i++){
        j=v[x][i];
        dfs(j);
        l=a[j];
        co[l]++;
    }
    g(i,4)if(co[i]==0){a[x]=i; break;}
    if(i==5)r=-1;

}

int main()
{
ios_base::sync_with_stdio(0);
ll k=0,x,sum=1,q=0,z=0,y=0,l=0,i,t,j;
cin>>n;
f(i,n){
    cin>>p[i].ff.ff>>p[i].ff.ss>>p[i].ss.ff>>p[i].ss.ss;
    in[mp(mp(p[i].ff.ff,p[i].ff.ss),mp(p[i].ss.ff,p[i].ss.ss) )]=i+1;
}
sort(p,p+n);
f(i,n){
    for(j=i+1;j<n;j++){
        if(p[j].ff.ff>p[i].ss.ff)break;
          if(p[i].ss.ff == p[j].ff.ff && p[i].ss.ss==p[j].ff.ss)break;
          if(p[i].ss.ff == p[j].ff.ss && p[i].ff.ss==p[j].ss.ss)continue;
        if((p[j].ff.ss >=p[i].ff.ss && p[j].ff.ss <= p[i].ss.ss) || (p[j].ss.ss >=p[i].ff.ss && p[j].ss.ss <= p[i].ss.ss)){
          v[i].pb(j); v[j].pb(i);
        } else if ((p[i].ff.ss >=p[j].ff.ss && p[i].ff.ss <= p[j].ss.ss) || (p[i].ss.ss >=p[j].ff.ss && p[j].ss.ss >= p[i].ss.ss)){
            v[i].pb(j); v[j].pb(i);
        }
    }
}
dfs(1);
if(r==-1)cout<<"NO";
else {
    cout<<"YES\n";
    f(i,n){
        t=a[i];
        l =in[mp(mp(p[i].ff.ff,p[i].ff.ss),mp(p[i].ss.ff,p[i].ss.ss) )];
        b[l]=t;
    }
    g(i,n){
        cout<<b[i]<<endl;
    }
}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define N 500005
#define ll long long
#define p(t) cout<<t;
#define f(i,n) for(i=0;i<n;i++)
#define g(i,n) for(i=1;i<=n;i++)
#define s(x) scanf("%I64d",&x);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll m,n,r,u,xc,yc,a[N],b[N],c[N];
pair<pair<ll,ll> ,pair<ll,ll> > p[N];
map<pair<pair<ll,ll> ,pair<ll,ll> > ,ll> in;
vector<ll> v[N];
void dfs(ll x, set<ll> tp){
    if(c[x]==1 || r==-1)return;
    c[x]=1;
    ll i,j,k,l;
    ll co[]= {0,0,0,0,0};
    set<ll> sp =tp;
   // cout<<sp.size();
    for(i=0;i<v[x].size();i++){
        j=v[x][i];
        dfs(j,tp);
        l=a[j];
        if(l==0)continue;
        tp.insert(l);
        co[l]++;
    }
    set<ll> :: iterator it;
    for(it= sp.begin(); it !=sp.end(); it++){
        k =*it;
        if(co[k]==0){a[x]=k; return;}
    }
    g(i,4)if(co[i]==0){a[x]=i; break;}
    if(i==5)r=-1;

}

int main()
{
ios_base::sync_with_stdio(0);
ll k=0,x,sum=1,q=0,z=0,y=0,l=0,i,t,j;
cin>>n;
f(i,n){
    cin>>p[i].ff.ff>>p[i].ff.ss>>p[i].ss.ff>>p[i].ss.ss;
    in[mp(mp(p[i].ff.ff,p[i].ff.ss),mp(p[i].ss.ff,p[i].ss.ss) )]=i+1;
}
sort(p,p+n);
f(i,n){
    for(j=i+1;j<n;j++){
        if(p[j].ff.ff>p[i].ss.ff)break;
          if(p[i].ss.ff == p[j].ff.ff && p[i].ss.ss==p[j].ff.ss)break;
          if(p[i].ss.ff == p[j].ff.ff && p[i].ff.ss==p[j].ss.ss)continue;
        if((p[j].ff.ss >=p[i].ff.ss && p[j].ff.ss <= p[i].ss.ss) || (p[j].ss.ss >=p[i].ff.ss && p[j].ss.ss <= p[i].ss.ss)){
          v[i].pb(j); v[j].pb(i);
        } else if ((p[i].ff.ss >=p[j].ff.ss && p[i].ff.ss <= p[j].ss.ss) || (p[i].ss.ss >=p[j].ff.ss && p[j].ss.ss >= p[i].ss.ss)){
            v[i].pb(j); v[j].pb(i);
        }
    }
}
set<ll>mk;
f(i,n){if(c[i]==0)dfs(i,mk);}
if(r==-1)cout<<"NO";
else {
    cout<<"YES\n";
    f(i,n){
        t=a[i];
        l =in[mp(mp(p[i].ff.ff,p[i].ff.ss),mp(p[i].ss.ff,p[i].ss.ss) )];
        b[l]=t;
        //cout<<l<<" "<<t;
    }
    g(i,n){
        cout<<b[i]<<endl;
    }
}
return 0;
}


#include<iostream>

using namespace std;

int main()
{
    cout<<"YES"<<endl;
    int x,y;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        cout<<2*x%2+y%2+1<<endl;
        cin>>x>>y;
    }
}


#include<iostream>

using namespace std;

int main()
{
    cout<<"YES"<<endl;
    int x,y;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        cout<<x%2*2+y%2+1<<endl;
        cin>>x>>y;
    }
}


#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    cout<<"YES"<<endl;
    int x,y;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        cout<<2*abs(x)%2+abs(y)%2+1<<endl;
        cin>>x>>y;
    }
}


#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    cout<<"YES"<<endl;
    int x,y;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        cout<<2*abs(x%2)+abs(y%2)+1<<endl;
        cin>>x>>y;
    }
}


#include <bits/stdc++.h>

using namespace std;
int main()
{
    int n;
    cin>>n;
    cout<<"YES"<<endl;
    for(int i=0;i<n;i++){
        int x1,x2,y1,y2,x,y;
        cin>>x1>>y1>>x2>>y2;
        x=abs(min(x1,x2));
        y=abs(min(y1,y2));
        if(x%2&&y%2)cout<<"4"<<endl;
        else if(x%2==0&&y%2==1)cout<<"3"<<endl;
        else if(x%2==1&&y%2==0)cout<<"2"<<endl;
        else if(x%2==0&&y%2==0)cout<<"1"<<endl;

    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAX = 1000010;

struct Node {
	int x1, x2, y1, y2;
}p[MAX];

struct N{
	int u, mark, k;  //mark 0->ru, 1->chu
	bool operator < (const N& args)const {
		if (u != args.u){
			return u < args.u;
		}
		return mark > args.mark;
	}

}q[MAX];

int n;
vector<int> G[MAX];
map<int, int>M;

void insert(int x, int k){
	if (M.find(x) != M.end()){
		int y = M[x];

		G[y].push_back(k);
		G[k].push_back(y);

		if (p[k].x2 > p[y].x2){
			M[x] = k;
		}
	}else{
		M[x] = k;
	}
}

void del(int x, int k){
	if (M.find(x) == M.end()){
		return;
	}
	if (M[x] == k){
		M.erase(x);
	}
}

void fx(){
	M.clear();
	int c = 0;
	for (int i = 1; i<=n; i++){
		q[c++] = (N){p[i].x1, 0, i};
		q[c++] = (N){p[i].x2, 1, i};
	}

	sort(q, q+c);

	for (int i = 0; i<c; i++){
		Node tmp = p[q[i].k];

		if (q[i].mark == 0){
			insert(tmp.y1, q[i].k);
			insert(tmp.y2, q[i].k);
		}else{
			del(tmp.y1, q[i].k);
			del(tmp.y2, q[i].k);
		}
	}
}

void fy(){
	M.clear();
	int c = 0;
	for (int i = 1; i<=n; i++){
		q[c++] = (N){p[i].y1, 0, i};
		q[c++] = (N){p[i].y2, 1, i};
	}

	sort(q, q+c);

	for (int i = 0; i<c; i++){

		Node tmp = p[q[i].k];

		if (q[i].mark == 0){
			insert(tmp.x1, q[i].k);
			insert(tmp.x2, q[i].k);
		}else{
			del(tmp.x1, q[i].k);
			del(tmp.x2, q[i].k);
		}
	}
}

int vis[MAX];

bool solve(int x){
	int tmp[5];
	memset(tmp, 0, sizeof(tmp));
	for (int i = 0; i<G[x].size(); i++){
		int u = G[x][i];
		tmp[vis[u]]  = 1;
	}

	bool ok  = false;
	for (int i = 1; i<=4; i++){
		if (tmp[i] == 0){
			vis[x] = i;
			ok = true;
			break;
		}
	}

	if (!ok){
		return false;
	}

	for (int i = 0; i<G[x].size(); i++){
		int u = G[x][i];
		if (!vis[u]){
			ok = (ok && solve(u));
		}
	}
	return ok;
}

int main(int argc, char const *argv[])
{
	/* code */
	while (scanf("%d", &n) != EOF){
		for (int i = 1; i<=n; i++){
			scanf("%d%d%d%d", &p[i].x1, &p[i].y1, &p[i].x2, &p[i].y2);
			if (p[i].x1 > p[i].x2){
				swap(p[i].x1, p[i].x2);
			}
			if (p[i].y1 > p[i].y2){
				swap(p[i].y1, p[i].y2);
			}
		}

		for (int i = 0; i<MAX; i++){
			G[i].clear();
		}

		fx();
		fy();

	//	memset(vis, 0, sizeof(vis));

		/*for (int i = 1; i<=n; i++){
			for (int j = 0; j<G[i].size(); j++){
				printf("%d ", G[i][j]);
			}
			printf("\n");
		}*/

		bool ans = true;

		for (int i = 1; i<=n; i++) if (!vis[i]){
			ans = (ans && solve(i));
		}

		if (ans){
			printf("YES\n");
			for (int i = 1; i<=n; i++){
				printf("%d\n", vis[i]);
			}
		}else{
			printf("NO\n");
		}

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAX = 1000010;

struct Node {
	int x1, x2, y1, y2;
}p[MAX];

struct N{
	int u, mark, k;  //mark 0->ru, 1->chu
	bool operator < (const N& args)const {
		if (u != args.u){
			return u < args.u;
		}
		return mark > args.mark;
	}

}q[MAX];

int n;
vector<int> G[MAX];
map<int, int>M;

void insert(int x, int k){
	if (M.find(x) != M.end()){
		int y = M[x];

		G[y].push_back(k);
		G[k].push_back(y);

		if (p[k].x2 > p[y].x2){
			M[x] = k;
		}
	}else{
		M[x] = k;
	}
}

void del(int x, int k){
	if (M.find(x) == M.end()){
		return;
	}
	if (M[x] == k){
		M.erase(x);
	}
}

void fx(){
	M.clear();
	int c = 0;
	for (int i = 1; i<=n; i++){
		q[c++] = (N){p[i].x1, 0, i};
		q[c++] = (N){p[i].x2, 1, i};
	}

	sort(q, q+c);

	for (int i = 0; i<c; i++){
		Node tmp = p[q[i].k];

		if (q[i].mark == 0){
			insert(tmp.y1, q[i].k);
			insert(tmp.y2, q[i].k);
		}else{
			del(tmp.y1, q[i].k);
			del(tmp.y2, q[i].k);
		}
	}
}

void fy(){
	M.clear();
	int c = 0;
	for (int i = 1; i<=n; i++){
		q[c++] = (N){p[i].y1, 0, i};
		q[c++] = (N){p[i].y2, 1, i};
	}

	sort(q, q+c);

	for (int i = 0; i<c; i++){

		Node tmp = p[q[i].k];

		if (q[i].mark == 0){
			insert(tmp.x1, q[i].k);
			insert(tmp.x2, q[i].k);
		}else{
			del(tmp.x1, q[i].k);
			del(tmp.x2, q[i].k);
		}
	}
}

int vis[MAX];

bool solve(int x){
	int tmp[5];
	memset(tmp, 0, sizeof(tmp));
	for (int i = 0; i<G[x].size(); i++){
		int u = G[x][i];
		tmp[vis[u]]  = 1;
	}

	bool ok  = false;
	for (int i = 1; i<=4; i++){
		if (tmp[i] == 0){
			vis[x] = i;
			ok = true;
			break;
		}
	}

	if (!ok){
		return false;
	}

	for (int i = 0; i<G[x].size(); i++){
		int u = G[x][i];
		if (!vis[u]){
			ok = (ok && solve(u));
		}
	}
	return ok;
}

int main(int argc, char const *argv[])
{
	/* code */
	while (scanf("%d", &n) != EOF){
		for (int i = 1; i<=n; i++){
			scanf("%d%d%d%d", &p[i].x1, &p[i].y1, &p[i].x2, &p[i].y2);
			if (p[i].x1 > p[i].x2){
				swap(p[i].x1, p[i].x2);
			}
			if (p[i].y1 > p[i].y2){
				swap(p[i].y1, p[i].y2);
			}
		}

		for (int i = 0; i<MAX; i++){
			G[i].clear();
		}

		fx();
		fy();

		memset(vis, 0, sizeof(vis));

		/*for (int i = 1; i<=n; i++){
			for (int j = 0; j<G[i].size(); j++){
				printf("%d ", G[i][j]);
			}
			printf("\n");
		}*/

		bool ans = true;

		for (int i = 1; i<=n; i++) if (!vis[i]){
			ans = (ans && solve(i));
		}

		if (ans){
			printf("YES\n");
			for (int i = 1; i<=n; i++){
				printf("%d\n", vis[i]);
			}
		}else{
			printf("NO\n");
		}

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAX = 1000010;

struct Node {
	int x1, x2, y1, y2;
}p[MAX];

struct N{
	int u, mark, k;  //mark 0->ru, 1->chu
	bool operator < (const N& args)const {
		if (u != args.u){
			return u < args.u;
		}
		return mark > args.mark;
	}

}q[MAX];

int n;
vector<int> G[MAX];
map<int, int>M;

void insertx(int x, int k){
	if (M.find(x) != M.end()){
		int y = M[x];

		G[y].push_back(k);
		G[k].push_back(y);

		if (p[k].x2 > p[y].x2){
			M[x] = k;
		}
	}else{
		M[x] = k;
	}
}

void inserty(int x, int k){
	if (M.find(x) != M.end()){
		int y = M[x];

		G[y].push_back(k);
		G[k].push_back(y);

		if (p[k].y2 > p[y].y2){
			M[x] = k;
		}
	}else{
		M[x] = k;
	}
}

void del(int x, int k){
	if (M.find(x) == M.end()){
		return;
	}
	if (M[x] == k){
		M.erase(x);
	}
}

void fx(){
	M.clear();
	int c = 0;
	for (int i = 1; i<=n; i++){
		q[c++] = (N){p[i].x1, 0, i};
		q[c++] = (N){p[i].x2, 1, i};
	}

	sort(q, q+c);

	for (int i = 0; i<c; i++){
		Node tmp = p[q[i].k];

		if (q[i].mark == 0){
			insertx(tmp.y1, q[i].k);
			insertx(tmp.y2, q[i].k);
		}else{
			del(tmp.y1, q[i].k);
			del(tmp.y2, q[i].k);
		}
	}
}

void fy(){
	M.clear();
	int c = 0;
	for (int i = 1; i<=n; i++){
		q[c++] = (N){p[i].y1, 0, i};
		q[c++] = (N){p[i].y2, 1, i};
	}

	sort(q, q+c);

	for (int i = 0; i<c; i++){
		Node tmp = p[q[i].k];

		if (q[i].mark == 0){
			inserty(tmp.x1, q[i].k);
			inserty(tmp.x2, q[i].k);
		}else{
			del(tmp.x1, q[i].k);
			del(tmp.x2, q[i].k);
		}
	}
}

int vis[MAX], tmp[5];

bool solve(int x){
	memset(tmp, 0, sizeof(tmp));
	for (int i = 0; i<G[x].size(); i++){
		int u = G[x][i];
		tmp[vis[u]]  = 1;
	}

	bool ok  = false;
	for (int i = 1; i<=4; i++){
		if (tmp[i] == 0){
			vis[x] = i;
			ok = true;
			break;
		}
	}

	if (!ok){
		return false;
	}

	for (int i = 0; i<G[x].size(); i++){
		int u = G[x][i];
		if (!vis[u]){
			ok = (ok && solve(u));
		}
	}
	return ok;
}

int main(int argc, char const *argv[])
{
	/* code */
	while (scanf("%d", &n) != EOF){
		for (int i = 1; i<=n; i++){
			scanf("%d%d%d%d", &p[i].x1, &p[i].y1, &p[i].x2, &p[i].y2);
			if (p[i].x1 > p[i].x2){
				swap(p[i].x1, p[i].x2);
			}
			if (p[i].y1 > p[i].y2){
				swap(p[i].y1, p[i].y2);
			}
		}

		for (int i = 0; i<MAX; i++){
			G[i].clear();
		}

		fx();
		fy();

		memset(vis, 0, sizeof(vis));

		/*for (int i = 1; i<=n; i++){
			for (int j = 0; j<G[i].size(); j++){
				printf("%d ", G[i][j]);
			}
			printf("\n");
		}*/

		bool ans = true;

		for (int i = 1; i<=n; i++) if (!vis[i]){
			ans = (ans && solve(i));
		}

		if (ans){
			printf("YES\n");
			for (int i = 1; i<=n; i++){
				printf("%d\n", vis[i]);
			}
		}else{
			printf("NO\n");
		}

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAX = 1000010;

struct Node {
	int x1, x2, y1, y2;
}p[MAX];

struct N{
	int u, mark, k;  //mark 0->ru, 1->chu
	bool operator < (const N& args)const {
		if (u != args.u){
			return u < args.u;
		}
		return mark > args.mark;
	}

}q[MAX];

int n;
vector<int> G[MAX];
map<int, int>M;

void insertx(int x, int k){
	if (M.find(x) != M.end()){
		int y = M[x];

		G[y].push_back(k);
		G[k].push_back(y);

		if (p[k].x2 > p[y].x2){
			M[x] = k;
		}
	}else{
		M[x] = k;
	}
}

void inserty(int x, int k){
	if (M.find(x) != M.end()){
		int y = M[x];

		G[y].push_back(k);
		G[k].push_back(y);

		if (p[k].y2 > p[y].y2){
			M[x] = k;
		}
	}else{
		M[x] = k;
	}
}

void del(int x, int k){
	if (M.find(x) == M.end()){
		return;
	}
	if (M[x] == k){
		M.erase(x);
	}
}

void fx(){
	M.clear();
	int c = 0;
	for (int i = 1; i<=n; i++){
		q[c++] = (N){p[i].x1, 0, i};
		q[c++] = (N){p[i].x2, 1, i};
	}

	sort(q, q+c);

	for (int i = 0; i<c; i++){
		Node tmp = p[q[i].k];

		if (q[i].mark == 0){
			insertx(tmp.y1, q[i].k);
			insertx(tmp.y2, q[i].k);
		}else{
			del(tmp.y1, q[i].k);
			del(tmp.y2, q[i].k);
		}
	}
}

void fy(){
	M.clear();
	int c = 0;
	for (int i = 1; i<=n; i++){
		q[c++] = (N){p[i].y1, 0, i};
		q[c++] = (N){p[i].y2, 1, i};
	}

	sort(q, q+c);

	for (int i = 0; i<c; i++){
		Node tmp = p[q[i].k];

		if (q[i].mark == 0){
			inserty(tmp.x1, q[i].k);
			inserty(tmp.x2, q[i].k);
		}else{
			del(tmp.x1, q[i].k);
			del(tmp.x2, q[i].k);
		}
	}
}

int vis[MAX];

bool solve(int x){
	int tmp[5];
	memset(tmp, 0, sizeof(tmp));
	for (int i = 0; i<G[x].size(); i++){
		int u = G[x][i];
		tmp[vis[u]]  = 1;
	}

	bool ok  = false;
	for (int i = 1; i<=4; i++){
		if (tmp[i] == 0){
			vis[x] = i;
			ok = true;
			break;
		}
	}

	if (!ok){
		return false;
	}

	for (int i = 0; i<G[x].size(); i++){
		int u = G[x][i];
		if (!vis[u]){
			ok = (ok && solve(u));
		}
	}
	return ok;
}

int main(int argc, char const *argv[])
{
	/* code */
	while (scanf("%d", &n) != EOF){
		for (int i = 1; i<=n; i++){
			scanf("%d%d%d%d", &p[i].x1, &p[i].y1, &p[i].x2, &p[i].y2);
			if (p[i].x1 > p[i].x2){
				swap(p[i].x1, p[i].x2);
			}
			if (p[i].y1 > p[i].y2){
				swap(p[i].y1, p[i].y2);
			}
		}

		for (int i = 0; i<MAX; i++){
			G[i].clear();
		}

		fx();
		fy();

		memset(vis, 0, sizeof(vis));

		/*for (int i = 1; i<=n; i++){
			for (int j = 0; j<G[i].size(); j++){
				printf("%d ", G[i][j]);
			}
			printf("\n");
		}*/

		bool ans = true;

		for (int i = 1; i<=n; i++) if (!vis[i]){
			ans = (ans && solve(i));
		}

		if (ans){
			printf("YES\n");
			for (int i = 1; i<=n; i++){
				printf("%d\n", vis[i]);
			}
		}else{
			printf("NO\n");
		}

	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAX = 500010;

int a[MAX];

int main(int argc, char const *argv[])
{
	/* code */

	int n;
	int x1, y1, x2, y2;
	while (scanf("%d", &n)!= EOF){
		for (int i = 0; i<n; i++){
			scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

			int u = abs(x1) % 2;
			int v = abs(y1) % 2;

			if (u==0 && v==0){
				a[i] = 1;
			}else if (u ==0 && v == 1){
				a[i] = 2;
			}else if (u == 1 && v == 0){
				a[i] = 3;
			}else{
				a[i] = 4;
			}
		}

		printf("YES\n");

		for (int i = 0; i<n; i++){
			printf("%d\n", a[i]);
		}

	}
	return 0;
}


/* DHUOJ solution #359923 @ 2018-08-06 10:09:30.317 */

#include <bits/stdc++.h>

using namespace std;
const int NUM=5e5+10;
int ans[NUM];
int main()
{
    int n,a,b,c,d;
    scanf("%d",&n);
    for (int i=1; i<=n; i++)
    {
        scanf("%d%d%d%d",&a,&b,&c,&d);
        if (a%2&&b%2)
            ans[i]=1;
        else if(a%2==0&&b%2)
            ans[i]=2;
        else if(a%2&&b%2==0)
            ans[i]=3;
        else
            ans[i]=4;
    }
    puts("YES");
    for (int i=1; i<=n; i++)
        printf("%d\n",ans[i]);
    return 0;
}


#include<bits/stdc++.h>
    int n,a,b,c,d;
int main(){
    scanf("%d",&n);
    puts("YES");
    while(n--){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        printf("%d\n",2*(abs(a)&1)+(abs(b)&1)+1);
    }
    return 0;
}


#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
using namespace std;
int n,x,y,xx,yy;
int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}
int main(){

    n=IN();
    puts("YES");
    For(i,0,n){
        x=IN(),y=IN(),xx=IN(),yy=IN();
        if(x&1){
            if(y&1)
                puts("1");
            else
                puts("2");
        }else{
            if(y&1)
                puts("3");
            else
                puts("4");
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}
int main(){
    int n,x,y,xx,yy;
    n=IN();
    puts("YES");
    for(int i=0;i<n;i++){
        x=IN(),y=IN(),IN(),IN();
        if(x&1){ if(y&1) puts("1"); else puts("2");}
        else { if(y&1) puts("3"); else puts("4");}
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y,xx,yy;
    scanf("%d",&n);
    printf("YES\n");
    for(int i=0;i<n;i++){
        scanf("%d%d%*d%*d",&x,&y);
        printf("%d\n",(2*(x&1))+(1<<(y&1)));
    }
}


#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
using namespace std;
int n,x,y,c;
int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}
int main(){

    n=IN();
    puts("YES");
    For(i,0,n){
        x=IN(),y=IN(),c=IN(),c=IN();
        if(x&1){
            if(y&1)
                puts("1");
            else
                puts("2");
        }else{
            if(y&1)
                puts("3");
            else
                puts("4");
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
const int mx=2e5+10;
inline int getint(){
    int w=0,q=0; char c=getchar(); while((c<'0'||c>'9') && c!='-') c=getchar();
    if(c=='-') q=1,c=getchar(); while (c>='0'&&c<='9') w=w*10+c-'0',c=getchar(); return q?-w:w;
}
int main(){
    int n,x,y;cin>>n;
    cout<<"YES\n";
    for(int i=0;i<n;i++){
        x=getint(),y=getint(),getint(),getint();
        if(x&1) printf("%d\n",((y&1)?1:2));
        else printf("%d\n",((y&1)?3:4));
    }
}


#include<bits/stdc++.h>
using namespace std;
inline int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}
int main(){
    int n,x,y,xx,yy;
    n=IN();
    puts("YES");
    for(int i=0;i<n;i++){
        x=IN(),y=IN(),IN(),IN();
        if(x&1){ if(y&1) puts("1"); else puts("2");}
        else { if(y&1) puts("3"); else puts("4");}
    }
}


#include<bits/stdc++.h>
using namespace std;
inline int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}
int main(){
    int n,x,y,xx,yy;
    n=IN();
    string s;
    puts("YES");
    for(int i=0;i<n;i++){
        x=IN(),y=IN();
        getline(cin,s);
        if(x&1){ if(y&1) puts("1"); else puts("2");}
        else { if(y&1) puts("3"); else puts("4");}
    }
}


#include<bits/stdc++.h>
using namespace std;
inline int getint(){
    int w=0,q=0; char c=getchar(); while((c<'0'||c>'9') && c!='-') c=getchar();
    if(c=='-') q=1,c=getchar(); while (c>='0'&&c<='9') w=w*10+c-'0',c=getchar(); return q?-w:w;
}
int main(){
    int n,x,y,xx,yy;
    scanf("%d",&n);
    printf("YES\n");
    for(int i=0;i<n;i++){
        scanf("%d%d%d%d",&x,&y,&xx,&yy);
        if(x&1) printf("%d\n",((y&1)?1:2));
        else printf("%d\n",((y&1)?3:4));
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y,xx,yy;
    scanf("%d",&n);
    printf("YES\n");
    for(int i=0;i<n;i++){
        scanf("%d%d%d%d",&x,&y,&yy,&xx);
        printf("%d\n",(2*(x&1))+(1<<(y&1)));
    }
}


#include<bits/stdc++.h>
using namespace std;
int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}
int main(){
    int n,x,y,xx,yy;
    n=IN();
    puts("YES");
    for(int i=0;i<n;i++){
        x=IN(),y=IN(),xx=IN(),yy=IN();
        if(x&1){
            if(y&1)
                puts("1");
            else
                puts("2");
        }else{
            if(y&1)
                puts("3");
            else
                puts("4");
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
const int mx=2e5+10;
int main(){
    int n,x,c,y;cin>>n;
    cout<<"YES\n";
    for(int i=0;i<n;i++){ cin>>x>>y>>c>>c;
        if(x%2) cout<<((y%2)?1:2);
        else cout<<((y%2)?3:4);
    }
}


#include<bits/stdc++.h>
using namespace std;
const int mx=2e5+10;
int main(){
    int n,x,c,y;cin>>n;
    cout<<"YES\n";
    for(int i=0;i<n;i++){ cin>>x>>y>>c>>c;
        if(x%2) cout<<((y%2)?1:2);
        else cout<<((y%2)?3:4);
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
inline int getint(){
    int w=0,q=0; char c=getchar(); while((c<'0'||c>'9') && c!='-') c=getchar();
    if(c=='-') q=1,c=getchar(); while (c>='0'&&c<='9') w=w*10+c-'0',c=getchar(); return q?-w:w;
}
int main(){
    int n,x,y;
    n=getint();
    printf("YES\n");
    for(int i=0;i<n;i++){
        x=getint(),y=getint(),getint(),getint();
        if(x&1) printf("%d\n",((y&1)?1:2));
        else printf("%d\n",((y&1)?3:4));
    }
}


#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,l,r,u,d;
	scanf("%d",&n);
	puts("YES");
	for (int i=1;i<=n;++i){
		scanf("%d%d%d%d",&l,&r,&u,&d);
		printf("%d\n",((l&1)<<1)+(u&1)+1);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,l,r,u,d;
	scanf("%d",&n);
	puts("YES");
	for (int i=1;i<=n;++i){
		scanf("%d%d%d%d",&l,&r,&u,&d);
		l+=1e9,u+=1e9;
		printf("%d\n",((l&1)<<1)+(u&1)+1);
	}
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,l,r,u,d;
	scanf("%d",&n);
	puts("YES");
	for (int i=1;i<=n;++i){
		scanf("%d%d%d%d",&l,&u,&r,&d);
		l+=1e9;u+=1e9;
		printf("%d\n",((l&1)<<1)+(u&1)+1);
	}
	return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define MOD 1000000007
struct Node
{
    int x1,x2,y1,y2;
}num[500005];
int color[500005];
map <int,int> mx,my;
vector <int> xx[1000005],yy[1000005],v[500005];
int cntx=0,cnty=0;
int life1[500005],life2[500005],life3[500005],life4[500005];
int main()
{
    int a,b;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d%d",&num[i].x1,&num[i].y1,&num[i].x2,&num[i].y2);
        if(mx[num[i].x1]==0)
        {
            cntx++;
            mx[num[i].x1]=cntx;
            xx[cntx].push_back(i);
        }
        else
            xx[mx[num[i].x1]].push_back(i);
        if(mx[num[i].x2]==0)
        {
            cntx++;
            mx[num[i].x2]=cntx;
        }
        if(my[num[i].y1]==0)
        {
            cnty++;
            my[num[i].y1]=cnty;
            yy[cnty].push_back(i);
        }
        else
            yy[my[num[i].y1]].push_back(i);
        if(my[num[i].y2]==0)
        {
            cnty++;
            my[num[i].y2]=cnty;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<xx[mx[num[i].x2]].size();j++)
        {
            a=xx[mx[num[i].x2]][j];
            if(num[i].y1<num[a].y2 && num[i].y2>num[a].y1)
            {
                v[i].push_back(a);
                v[a].push_back(i);
            }
        }
        for(int j=0;j<yy[my[num[i].y2]].size();j++)
        {
            a=yy[my[num[i].y2]][j];
            if(num[i].x1<num[a].x2 && num[i].x2>num[a].x1)
            {
                v[i].push_back(a);
                v[a].push_back(i);
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!life1[i])
        {
            color[i]=1;
            life2[i]=life3[i]=life4[i]=1;
            for(int j=0;j<v[i].size();j++)
                life1[v[i][j]]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!life2[i])
        {
            color[i]=2;
            life1[i]=life3[i]=life4[i]=1;
            for(int j=0;j<v[i].size();j++)
                life2[v[i][j]]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!life3[i])
        {
            color[i]=3;
            life1[i]=life2[i]=life4[i]=1;
            for(int j=0;j<v[i].size();j++)
                life3[v[i][j]]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!life4[i])
        {
            color[i]=4;
            life1[i]=life2[i]=life3[i]=1;
            for(int j=0;j<v[i].size();j++)
                life4[v[i][j]]=1;
        }
    }
    printf("YES\n");
    for(int i=1;i<=n;i++)
        printf("%d\n",color[i]);
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define MOD 1000000007
struct Node
{
    int x1,x2,y1,y2;
}num[500005];
int color[500005];
map <int,int> mx,my;
vector <int> xx[1000005],yy[1000005],v[500005];
int cntx=0,cnty=0;
int life1[500005],life2[500005],life3[500005],life4[500005];
int main()
{
    int a,b;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d%d",&num[i].x1,&num[i].y1,&num[i].x2,&num[i].y2);
        if(mx[num[i].x1]==0)
        {
            cntx++;
            mx[num[i].x1]=cntx;
            xx[cntx].push_back(i);
        }
        else
            xx[mx[num[i].x1]].push_back(i);
        if(mx[num[i].x2]==0)
        {
            cntx++;
            mx[num[i].x2]=cntx;
        }
        if(my[num[i].y1]==0)
        {
            cnty++;
            my[num[i].y1]=cnty;
            yy[cnty].push_back(i);
        }
        else
            yy[my[num[i].y1]].push_back(i);
        if(my[num[i].y2]==0)
        {
            cnty++;
            my[num[i].y2]=cnty;
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<xx[mx[num[i].x2]].size();j++)
        {
            a=xx[mx[num[i].x2]][j];
            if(num[i].y1<num[a].y2 && num[i].y2>num[a].y1)
            {
                v[i].push_back(a);
                v[a].push_back(i);
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!life1[i])
        {
            color[i]=1;
            life2[i]=life3[i]=life4[i]=1;
            for(int j=0;j<v[i].size();j++)
                life1[v[i][j]]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!life2[i])
        {
            color[i]=2;
            life1[i]=life3[i]=life4[i]=1;
            for(int j=0;j<v[i].size();j++)
                life2[v[i][j]]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!life3[i])
        {
            color[i]=3;
            life1[i]=life2[i]=life4[i]=1;
            for(int j=0;j<v[i].size();j++)
                life3[v[i][j]]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(!life4[i])
        {
            color[i]=4;
            life1[i]=life2[i]=life3[i]=1;
            for(int j=0;j<v[i].size();j++)
                life4[v[i][j]]=1;
        }
    }
    printf("YES\n");
    for(int i=1;i<=n;i++)
        printf("%d\n",color[i]);
    return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#define pq priority_queue
#define Pi acos(-1.0)
using namespace std;
#define MOD 1000000007
int color[500005];
int main()
{
    int n,x1,y1,x2,y2;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        if(x1%2)
        {
            if(y1%2)
                color[i]=1;
            else
                color[i]=2;
        }
        else
        {
            if(y1%2)
                color[i]=3;
            else
                color[i]=4;
        }
    }
    printf("YES\n");
    for(int i=1;i<=n;i++)
        printf("%d\n",color[i]);
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100000
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(){
    cin >> n;
    cout << "YES" << endl;
    rep(i,n){
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        cout << 2*abs(x1%2)+abs(y1%2)+1 << endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100000
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(){
    cin >> n;
    cout << "YES" << endl;
    rep(i,n){
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        cout << abs(x1%2)+abs(y1%2)+1 << endl;
    }
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100000
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(){
    scanf("%d",&n);
    puts("YES");
    rep(i,n){
        int x1, x2, y1, y2;
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        printf("%d\n",2*abs(x1%2)+abs(y1%2)+1);
    }
}


#include <bits/stdc++.h>
#define ll long long
#define maxn 100005
using namespace std;
char inp[maxn];
int fl[maxn];
int main() {
	int n;
	cin >> n;
	cout << "YES" << endl;
	for (int i = 1; i <= n; i++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		int nc = 0;
		if (x1 % 2) nc += 2;
		if (y1 % 2) nc ++;
		printf("%d\n", nc);
	}
 	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define maxn 100005
using namespace std;
char inp[maxn];
int fl[maxn];
int main() {
	int n;
	cin >> n;
	cout << "YES" << endl;
	for (int i = 1; i <= n; i++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		int nc = 0;
		if (x1 % 2) nc += 2;
		if (y1 % 2) nc ++;
		printf("%d\n", nc + 1);
	}
 	return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long MX = 300300;
const long long MAGIC = sqrt(N);
const long long mod = 1e9 + 7;

using namespace std;

int n;

void solve()
{
        cin >> n;
        cout << "YES\n";
        for(int i = 1; i <= n; i++)
        {
                int x1, y1, x2, y2;
                cin >> x1 >> y1 >> x2 >> y2;
                cout << (x1 & 1) + (y1 &1) * 2 + 1 << endl;
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("friendcross.in");
        //fout("friendcross.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const int N = 500500;
const int MX = 300300;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int dx[N];
int dy[N];
int ux[N];
int uy[N];
int ans[N];
bool used[N];
map < int, set < pair < int, int > > > d1, d2, d3, d4;
map < int, set < pair < int, int > > > u1, u2, u3, u4;

void dfs(int x)
{
    vector < int > v;
    set < pair < int, int > > :: iterator it;
    if(d2.find(dx[x] - 1) != d2.end()){
        it = d2[dx[x] - 1].lower_bound({dy[x], -1});
        while(it != d2[dx[x] - 1].end() && it->fi <= uy[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(d1.find(ux[x] + 1) != d1.end()){
        it = d1[ux[x] + 1].lower_bound({dy[x], -1});
        while(it != d1[ux[x] + 1].end() && it->fi <= uy[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(d4.find(dy[x] - 1) != d4.end()){
        it = d4[dy[x] - 1].lower_bound({dx[x], -1});
        while(it != d4[dy[x] - 1].end() && it->fi <= ux[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(d3.find(uy[x] + 1) != d3.end()){
        it = d3[uy[x] + 1].lower_bound({dx[x], -1});
        while(it != d3[uy[x] + 1].end() && it->fi <= ux[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(u2.find(dx[x] - 1) != u2.end()){
        it = u2[dx[x] - 1].lower_bound({dy[x], -1});
        while(it != u2[dx[x] - 1].end() && it->fi <= uy[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(u1.find(ux[x] + 1) != u1.end()){
        it = u1[ux[x] + 1].lower_bound({dy[x], -1});
        while(it != u1[ux[x] + 1].end() && it->fi <= uy[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(u4.find(dy[x] - 1) != u4.end()){
        it = u4[dy[x] - 1].lower_bound({dx[x], -1});
        while(it != u4[dy[x] - 1].end() && it->fi <= ux[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(u3.find(uy[x] + 1) != u3.end()){
        it = u3[uy[x] + 1].lower_bound({dx[x], -1});
        while(it != u3[uy[x] + 1].end() && it->fi <= ux[x]){
            v.pb(it->se);
            it++;
        }
    }
    used[x] = true;
    bool us[5] = {0, 0, 0, 0, 0};
    for(int y: v)
        if(used[y])
            us[ans[y]] = true;
    for(int i = 1; i <= 4; i++)
        if(!us[i])
            ans[x] = i;
    if(!ans[x]){
        cout << "NO" << endl;
        exit(0);
    }
    for(int y: v)
        if(!used[y])
            dfs(y);
}

void solve()
{
    sc("%d", &n);
    for(int i = 1; i <= n; i++){
        sc("%d%d%d%d", &dx[i], &dy[i], &ux[i], &uy[i]);
        if(dx[i] > dy[i])
            swap(dx[i], dy[i]);
        if(ux[i] > uy[i])
            swap(ux[i], uy[i]);
        d1[dx[i]].insert({dy[i], i});
        d2[ux[i]].insert({dy[i], i});
        d3[dy[i]].insert({dx[i], i});
        d4[uy[i]].insert({dx[i], i});
        u1[dx[i]].insert({uy[i], i});
        u2[ux[i]].insert({uy[i], i});
        u3[dy[i]].insert({ux[i], i});
        u4[uy[i]].insert({ux[i], i});
    }
    for(int i = 1; i <= n; i++)
        if(!used[i])
            dfs(i);
    pr("YES\n");
    for(int i = 1; i <= n; i++)
        pr("%d\n", ans[i]);
}

bool mtest = false; int main()
{
    //fin("input.txt");
    //fout("output.txt");
    ios_base::sync_with_stdio(0);
    int t = 1;
    if(mtest)
        cin >> t;
    while(t--)
        solve();
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const int N = 500500;
const int MX = 300300;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int dx[N];
int dy[N];
int ux[N];
int uy[N];
int ans[N];
bool used[N];
map < int, set < pair < int, int > > > d1, d2, d3, d4;
map < int, set < pair < int, int > > > u1, u2, u3, u4;

void dfs(int x)
{
    vector < int > v;
    set < pair < int, int > > :: iterator it;
    if(d2.find(dx[x]) != d2.end()){
        it = d2[dx[x]].lower_bound({dy[x], -1});
        while(it != d2[dx[x]].end() && it->fi <= uy[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(d1.find(ux[x]) != d1.end()){
        it = d1[ux[x]].lower_bound({dy[x], -1});
        while(it != d1[ux[x]].end() && it->fi <= uy[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(d4.find(dy[x]) != d4.end()){
        it = d4[dy[x]].lower_bound({dx[x], -1});
        while(it != d4[dy[x]].end() && it->fi <= ux[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(d3.find(uy[x]) != d3.end()){
        it = d3[uy[x]].lower_bound({dx[x], -1});
        while(it != d3[uy[x]].end() && it->fi <= ux[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(u2.find(dx[x]) != u2.end()){
        it = u2[dx[x]].lower_bound({dy[x], -1});
        while(it != u2[dx[x]].end() && it->fi <= uy[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(u1.find(ux[x]) != u1.end()){
        it = u1[ux[x]].lower_bound({dy[x], -1});
        while(it != u1[ux[x]].end() && it->fi <= uy[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(u4.find(dy[x]) != u4.end()){
        it = u4[dy[x]].lower_bound({dx[x], -1});
        while(it != u4[dy[x]].end() && it->fi <= ux[x]){
            v.pb(it->se);
            it++;
        }
    }
    if(u3.find(uy[x]) != u3.end()){
        it = u3[uy[x]].lower_bound({dx[x], -1});
        while(it != u3[uy[x]].end() && it->fi <= ux[x]){
            v.pb(it->se);
            it++;
        }
    }
    used[x] = true;
    bool us[5] = {0, 0, 0, 0, 0};
    for(int y: v)
        if(used[y])
            us[ans[y]] = true;
    for(int i = 1; i <= 4; i++)
        if(!us[i])
            ans[x] = i;
    if(!ans[x]){
        cout << "NO" << endl;
        exit(0);
    }
    for(int y: v)
        if(!used[y])
            dfs(y);
}

void solve()
{
    sc("%d", &n);
    for(int i = 1; i <= n; i++){
        sc("%d%d%d%d", &dx[i], &dy[i], &ux[i], &uy[i]);
        if(dx[i] > dy[i])
            swap(dx[i], dy[i]);
        if(ux[i] > uy[i])
            swap(ux[i], uy[i]);
        d1[dx[i]].insert({dy[i], i});
        d2[ux[i]].insert({dy[i], i});
        d3[dy[i]].insert({dx[i], i});
        d4[uy[i]].insert({dx[i], i});
        u1[dx[i]].insert({uy[i], i});
        u2[ux[i]].insert({uy[i], i});
        u3[dy[i]].insert({ux[i], i});
        u4[uy[i]].insert({ux[i], i});
    }
    for(int i = 1; i <= n; i++)
        if(!used[i])
            dfs(i);
    pr("YES\n");
    for(int i = 1; i <= n; i++)
        pr("%d\n", ans[i]);
}

bool mtest = false; int main()
{
    //fin("input.txt");
    //fout("output.txt");
    ios_base::sync_with_stdio(0);
    int t = 1;
    if(mtest)
        cin >> t;
    while(t--)
        solve();
}


#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define rans hans
#define X first
#define Y second
const int N=5e5+5;
pii x[N],y[N];
map<int,vector<pii> > mpx;
map<int,vector<pii> > mpy;
int dp[N][5];
vector<vector<int> > adj;
vector<int> topo;
int visited[N];
/*
 *void dfs(int v)
 *{
 *    for(int i=0;i<adj[v].size();i++)
 *    {
 *        if(visited[adj[v][i]]==1)
 *            continue;
 *        int u=adj[v][i];
 *        visited[u]=1;
 *        dfs(u);
 *    }
 *    topo.push_back(v);
 *}
 */
int col[N];
bool dfs(int v,int c)
{
	visited[v]=1;
	col[v]=c;
	bool rekt=false;
	for(int i=0;i<adj[v].size();i++)
	{
		int u=adj[v][i];
		if(visited[u]==1)
		if(col[u]==c)
		{
			rekt=true;
			break;
		}
		if(visited[u]!=1)
		{
			bool posi=false;
			for(int j=1;j<=4;j++)
			{
				if(j==c)
					continue;
				bool val=dfs(u,j);
				if(val==true)
				{
					posi=true;
					break;
				}
			}
			if(posi==false)
			{
				rekt=true;
				break;
			}
		}
	}
	if(rekt)
	{
		visited[v]=0;
		col[v]=0;
		return false;
	}
	return true;
}
//int col[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d%d",&x[i].X,&y[i].X,&x[i].Y,&y[i].Y);
		mpx[x[i].X].push_back(pii(y[i].X,i));
		mpy[y[i].X].push_back(pii(x[i].X,i));
	}
	for(map<int,vector<pii> >::iterator it=mpx.begin();it!=mpx.end();it++ )
	{
		sort(it->second.begin(),it->second.end());
	}
	for(map<int,vector<pii> >::iterator it=mpx.begin();it!=mpx.end();it++ )
	{
		sort(it->second.begin(),it->second.end());
	}
	adj.resize(n+5);
	for(int i=1;i<=n;i++)
	{
		int cur=x[i].Y;
		if(mpx.find(cur)==mpx.end())
			continue;
		int lans,hans;
		int lower=y[i].Y+1,higher=y[i].X;
		lans=n+5,hans=-1;
		int l=0,r=mpx[cur].size()-1;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(mpx[cur][mid].X>=lower)
			{
				lans=min(lans,mid);
				r=mid-1;
			}
			else
			{
				l=mid+1;
			}
		}
		l=0,r=mpx[cur].size()-1;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(mpx[cur][mid].X<=higher)
			{
				rans=max(rans,mid);
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		for(int j=lans;j<=rans;j++)
		{
			adj[i].push_back(mpx[cur][j].Y);
			adj[mpx[cur][j].Y].push_back(i);
		}
	}
	for(int i=1;i<=n;i++)
	{
		int cur=y[i].Y;
		int lans,hans;
		int lower=x[i].X,higher=x[i].Y-1;
		lans=n+5,hans=-1;
		if(mpy.find(cur)==mpy.end())
			continue;
		int l=0,r=mpy[cur].size()-1;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(mpy[cur][mid].X>=lower)
			{
				lans=min(lans,mid);
				r=mid-1;
			}
			else
			{
				l=mid+1;
			}
		}
		l=0,r=mpy[cur].size()-1;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(mpy[cur][mid].X<=higher)
			{
				rans=max(rans,mid);
				l=mid+1;
			}
			else
			{
				r=mid-1;
			}
		}
		for(int j=lans;j<=rans;j++)
		{
			adj[i].push_back(mpy[cur][j].Y);
			adj[mpy[cur][j].Y].push_back(i);
		}
	}
	memset(dp,0,sizeof(dp));
	memset(visited,0,sizeof(visited));
	for(int i=1;i<=n;i++)
	{
		if(visited[i]==1)
			continue;
		for(int j=1;j<=4;j++)
		{
			bool val=dfs(i,j);
			if(val==false)
				continue;
			else break;
		}
	}
	cout<<"YES"<<endl;
	for(int i=1;i<=n;i++)
		cout<<col[i]<<endl;
	/*
	 *for(int i=0;i<n;i++)
	 *{
	 *    int v=topo[i];
	 *    for(int c=1;c<=4;c++)
	 *    {
	 *        bool posi=true;
	 *        for(int k=0;k<adj[v].size();i++)
	 *        {
	 *            bool tans=false;
	 *            for(int oth=1;oth<=4;oth++)
	 *            if(dp[v][oth]==1&&oth!=c)
	 *                tans=true;
	 *            posi=posi||tans;
	 *        }
	 *        if(!posi)
	 *            dp[v][c]=0;
	 *        else dp[v][c]=1;
	 *    }
	 *}
	 *memset(visited,0,sizeof(visited));
	 *for(int i=1;i<=n;i++)
	 *{
	 *    if(visited[i]==1)
	 *        continue;
	 *    visited[i]=1;
	 *    for(int c=1;c<=4;c++)
	 *        if(dp[v][c]==1)
	 *
	 *}
	 */
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<‘0‘||c>‘9‘){if(c==‘-‘)f=-1; c=getchar();}
    while(c>=‘0‘&&c<=‘9‘){x=x*10+c-‘0‘; c=getchar();}
    return x*f;
}
int n,x,y;
int main(int argc, const char * argv[]) {
    n=read();
    puts("YES");
    for(int i=1;i<=n;i++){
        x=read();y=read();
        x=min(x,read());y=min(y,read());
        if(x&1){
            if(y&1) puts("1");
            else puts("2");
        }else{
            if(y&1) puts("3");
            else puts("4");
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	cout << "YES\n";
	int x1, x2, x, y1, y2, y;
	for (int i = 0; i < n; ++i)
	{
		cin >> x1 >> y1 >> x2 >> y2;
		x = min(x1, x2) % 2;
		y = min(y1, y2) % 2;

		x += 2;
		y += 2;
		x %= 2;
		y %= 2;
		if(x == 0 && y == 0)
			cout << 1;
		else if(x == 0 && y == 1)
			cout << 2;
		else if(x == 1 && y == 1)
			cout << 3;
		else
			cout << 4;
		cout << endl;

	}
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	cout << "YES\n";
	int x1, x2, x, y1, y2, y;
	for (int i = 0; i < n; ++i)
	{
		cin >> x1 >> y1 >> x2 >> y2;
		x = min(x1, x2) % 2;
		y = min(y1, y2) % 2;
		if(x == 0 && y == 0)
			cout << 1;
		else if(x == 0 && y == 1)
			cout << 2;
		else if(x == 1 && y == 1)
			cout << 3;
		else
			cout << 4;
		cout << endl;

	}
}


#include <bits/stdc++.h>

using namespace std;

int dfs(vector<vector<int>> t, int n, int s, int c[])
{
	bool mark[n] = {false};
	stack<int> tovisit;
	tovisit.push(s);
	mark[s] = true;
	int top;
	bool flag = false, flag1 = false, flag2 = false;
	int v1 = -1, v2 = -1;
	while(!tovisit.empty())
	{
		top = tovisit.top();
		tovisit.pop();
		auto it = t[top].begin();
		while(it != t[top].end())
		{
			if(!mark[*it])
			{
				if(c[top] != c[*it])
				{
					if(v1 == -1)
					{
						v1 = top;
						v2 = *it;
					}
					else if(flag1)
					{
						if(top != v1 && *it != v1)
						{
							flag = true;
							break;
						}
					}
					else if(flag2)
					{
						if(top != v2 && *it != v2)
						{
							flag = true;
							break;
						}
					}
					else if(top == v1 || *it == v1)
					{
						flag1 = true;
					}
					else if(top == v2 || *it == v2)
					{
						flag2 = true;
					}
					else
					{
						flag = true;
						break;
					}
				}
				tovisit.push(*it);
				mark[*it] = true;
			}
			++it;
		}
	}
	if(flag)
		return 0;
	if(v1 == -1)
		++v1;
	if(v2 == -1)
		++v2;
	if(flag1)
		return v1 + 1;
	return v2 + 1;
}

int main(void)
{
	int n, u, v;
	cin >> n;
	vector< vector < int > > t(n);
	for (int i = 0; i < n - 1; ++i)
	{
		cin >> u >> v;
		t[--u].emplace_back(--v);
		t[v].emplace_back(u);
	}

	int c[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> c[i];
	}
	int flag = dfs(t, n, 0, c);
	if(!flag)
		cout << "NO\n";
	else cout << "YES\n" << flag << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int x1, x2, x, y1, y2, y;
	for (int i = 0; i < n; ++i)
	{
		cin >> x1 >> y1 >> x2 >> y2;
		x = min(x1, x2) % 2;
		y = min(y1, y2) % 2;
		if(x == 0 && y == 0)
			cout << 1;
		else if(x == 0 && y == 1)
			cout << 2;
		else if(x == 1 && y == 1)
			cout << 3;
		else
			cout << 4;
		cout << endl;

	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
//#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int main(){
	cin>>n;
	puts("YES");
	rep(i,n){
		int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
		printf("%d\n",(a%2)*2+(b%2)+1);
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;
typedef pair<double,int>Q;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
//#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
int main(){
	cin>>n;
	puts("YES");
	rep(i,n){
		int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d);
		printf("%d\n",(a%2+2)%2*2+(b%2+2)%2+1);
	}
}


#include<bits/stdc++.h>

using namespace std;

#ifdef LOCAL //compile with -DLOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<char> vch;
typedef vector<string> vstr;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;
typedef vector<vch> vvch;
typedef vector<vstr> vvstr;
typedef vector<ld> vld;
typedef vector<vld> vvld;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz(x) ((ll)x.size())

#define rep(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repi(i, a, b) for (int i = (int)a; i >= (int)b; i--)

void no() {
  cout << "NO\n";
  exit(0);
}

void yes() {
  cout << "YES\n";
}

int nxt() {
  int x;
  cin >> x;
  return x;
}

void solve() {
	int n = nxt();

	cout << "YES\n";
	rep(i, 0, n) {
		vi a(4);
		rep(j, 0, 4) cin >> a[j];
		cout << (2 * (a[0] & 1) + (a[1] & 1) + 1) << "\n";
	}
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int t = 1;

  // cin >> t;

  for (int tc = 1; tc <= t; tc++) {
    solve();
  }
}


#include<bits/stdc++.h>

using namespace std;

#ifdef LOCAL //compile with -DLOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<char> vch;
typedef vector<string> vstr;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;
typedef vector<vch> vvch;
typedef vector<vstr> vvstr;
typedef vector<ld> vld;
typedef vector<vld> vvld;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz(x) ((ll)x.size())

#define rep(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repi(i, a, b) for (int i = (int)a; i >= (int)b; i--)

void no() {
  cout << "NO\n";
  exit(0);
}

void yes() {
  cout << "YES\n";
}

int nxt() {
  int x;
  cin >> x;
  return x;
}

void solve() {
	int n = nxt();

	cout << "YES\n";
	rep(i, 0, n) {
		vi a(4);
		rep(j, 0, 4) cin >> a[j];
		int c;
		if (a[0] % 2 == 0) {
			if (a[1] % 2 == 0) c = 0;
			else c = 1;
		} else {
			if (a[1] % 2 == 0) c = 2;
			else c = 3;
		}
		cout << c + 1 << "\n";
	}
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int t = 1;

  // cin >> t;

  for (int tc = 1; tc <= t; tc++) {
    solve();
  }
}


// All Heil Fire Lord Zuko

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

const int N = 2000 + 19;
const int inf = 1000 * 1000 * 1000 + 19;

int n;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    cout << "YES\n";
    for (int i = 0; i < n; i ++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1 & 2 && y1 & 2)
            cout << 1 << "\n";
        if (x1 & 2 && !(y1 & 2))
            cout << 2 << "\n";
        if (!(x1 & 2) && y1 & 2)
            cout << 3 << "\n";
        if (!(x1 & 2) && !(y & 2))
            cout << 4 << "\n";
    }
    return 0;
}


// All Heil Fire Lord Zuko

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

const int N = 2000 + 19;
const int inf = 1000 * 1000 * 1000 + 19;

int n;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    cout << "YES\n";
    for (int i = 0; i < n; i ++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1 & 2 && y1 & 2)
            cout << 1 << "\n";
        if (x1 & 2 && !(y1 & 2))
            cout << 2 << "\n";
        if (!(x1 & 2) && y1 & 2)
            cout << 3 << "\n";
        if (!(x1 & 2) && !(y1 & 2))
            cout << 4 << "\n";
    }
    return 0;
}


// All Heil Fire Lord Zuko

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

const int N = 2000 + 19;
const int inf = 1000 * 1000 * 1000 + 19;

int n;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    cout << "YES\n";
    for (int i = 0; i < n; i ++) {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1 & 1 && y1 & 1)
            cout << 1 << "\n";
        if (x1 & 1 && !(y1 & 1))
            cout << 2 << "\n";
        if (!(x1 & 1) && y1 & 1)
            cout << 3 << "\n";
        if (!(x1 & 1) && !(y1 & 1))
            cout << 4 << "\n";
    }
    return 0;
}


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define N 2100000
using namespace std;
struct node{int y,nex;}a[4*N];
struct node1{int u,d,l,r;}A[N];
struct node2{int o,id,t,l,r;}q[2*N];
struct node3{int l,r,id;}B[N],C[N];
int fir[N],len,c[N],n,num,bl,cl;
bool b[5];
bool cmp(node2 x,node2 y)
{
	if(x.t<y.t) return 1;
	if(x.t>y.t) return 0;
	if(x.o<y.o) return 1;
	if(x.o>y.o) return 0;
	if(x.l<y.l) return 1;
	return 0;
}
void ins(int x,int y)
{
	a[++len].y=y;a[len].nex=fir[x];fir[x]=len;
}
void make()
{
	int j=1;
	for(int i=1;i<=bl;i++)
	{
		while(j<=cl && C[j].r<=B[i].l) j++;
		while(j<=cl && C[j].l<B[i].r)
		{
			ins(B[i].id,C[j].id);ins(C[j].id,B[i].id);
			if(C[j].r<B[i].r) j++;
			else break;
		}
	}
}
void solve()
{
	num=0;
	for(int i=1;i<=n;i++)
	{
		q[++num].o=0;q[num].id=i;q[num].t=A[i].l;q[num].l=A[i].d;q[num].r=A[i].u;
		q[++num].o=1;q[num].id=i;q[num].t=A[i].r;q[num].l=A[i].d;q[num].r=A[i].u;
	}
	sort(q+1,q+num+1,cmp);
	int i=1;
	while(i<=num)
	{
		int st=i;
		bl=cl=0;
		while(i<=num && q[i].t==q[st].t)
		{
			if(q[i].o==0) B[++bl].l=q[i].l,B[bl].r=q[i].r,B[bl].id=q[i].id;
			else C[++cl].l=q[i].l,C[cl].r=q[i].r,C[cl].id=q[i].id;
			i++;
		}
		make();
	}
}
int dfs(int x)
{
	bool b[5];
	for(int i=1;i<=4;i++) b[i]=0;
	for(int k=fir[x];k;k=a[k].nex)
	{
		int y=a[k].y;
		b[c[y]]=1;
	}
	for(int i=1;i<=4;i++) if(b[i]==0) {c[x]=i;return 1;}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d%d",&A[i].l,&A[i].d,&A[i].r,&A[i].u);
		if(A[i].l>A[i].r) swap(A[i].l,A[i].r);
		if(A[i].d>A[i].u) swap(A[i].d,A[i].u);
	}
	solve();
	for(int i=1;i<=n;i++)
		swap(A[i].l,A[i].d),swap(A[i].r,A[i].u);
	solve();
	for(int i=1;i<=n;i++)
		if(dfs(i)==0) {printf("NO\n");return 0;}
	printf("YES\n");
	for(int i=1;i<=n;i++) printf("%d\n",c[i]);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
LL a[maxn];
LL n,m,k;
map<LL,int>s;

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	LL st=1,ed=k,cnt=0,ti=0,x;
	for(int i=1; i<=m; i++){
		scanf("%lld",&x);
		while(ed<x){
			if(cnt){
				st=ed+1;
				ed=ed+cnt;
				cnt=0;
				ti++;
			}
			else {
				st=(x-ed-1)/k*k+ed+1;
				ed=st+k;
			}
		}
		if(x<=ed) {
			cnt++;
		}
	}
	if(cnt) ti++;

	printf("%lld",ti);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
LL a[maxn];
LL n,m,k;
map<LL,int>s;

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	LL st=1,ed=k,cnt=0,ti=0,x;
	for(int i=1; i<=m; i++){
		scanf("%lld",&x);
		while(ed<x){
			if(cnt){
				st=ed+1;
				ed=ed+cnt;
				cnt=0;
				ti++;
			}
			else {
				st=(x-st-1)/k*k+st;
				ed=st+k;
			}
		}
		if(x<=ed) {
			cnt++;
		}
	}
	if(cnt) ti++;

	printf("%lld",ti);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
LL a[maxn];
LL n,m,k;
map<LL,int>s;

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	for(int i=1; i<=m; i++){
		LL x;
		scanf("%lld",&x);
		s[x]=1;
	}
	LL st=1,ed=k,cnt=0,ti=0;
	while(st <= n){
		cnt=0;
		for(LL i=st; i<=ed; i++){
			if(s[i]) {
				cnt++;
			}
		}
		if(cnt){
			st=ed+1;
			ed=ed+cnt;
			ti++;
		}
		else {
			st=ed+1;
			ed=ed+k;
		}
		ed=min(ed,n);
	}
	printf("%lld",ti);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
LL a[maxn];
LL n,m,k;
map<LL,int>s;

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	LL st=1,ed=k,cnt=0,ti=0,x,flag;
	for(int i=1; i<=m; i++){
		scanf("%lld",&x);
		flag=0;
		while(ed<x){
			if(cnt){
				st=ed+1;
				ed=ed+cnt;
				cnt=0;
				ti++;
			}
			else {
				st=ed+1;
				ed=ed+k;
			}
			flag=1;
		}
		if(x<=ed) {
			cnt++;
		}
	}
	if(cnt>0) ti++;

	printf("%lld",ti);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
LL a[maxn];
LL n,m,k;
map<LL,int>s;

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	LL st=1,ed=k,cnt=0,ti=0,x;
	for(int i=1; i<=m; i++){
		scanf("%lld",&x);
		while(ed<x){
			if(cnt){
				st=ed+1;
				ed=ed+cnt;
				cnt=0;
				ti++;
			}
			else {
				st=(x-st-1)/k*k+ed+1;
				ed=st+k;
			}
		}
		if(x<=ed) {
			cnt++;
		}
	}
	if(cnt) ti++;

	printf("%lld",ti);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
LL a[maxn];
LL n,m,k;
map<LL,int>s;

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	LL st=1,ed=k,cnt=0,ti=0,x;
	for(int i=1; i<=m; i++){
		scanf("%lld",&x);
		while(ed<x){
			if(cnt){
				st=ed+1;
				ed=ed+cnt;
				cnt=0;
				ti++;
			}
			else {
				st=(x-st-1)/k*k+ed;
				ed=st+k;
			}
		}
		if(x<=ed) {
			cnt++;
		}
	}
	if(cnt) ti++;

	printf("%lld",ti);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
LL a[maxn];
LL n,m,k;
map<LL,int>s;

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	LL st=1,ed=k,cnt=0,ti=0,x;
	for(int i=1; i<=m; i++){
		scanf("%lld",&x);
		if(ed<x){
			if(cnt){
				st=ed+1;
				ed=ed+cnt;
				cnt=0;
				ti++;
			}
			else {
				st=(x-st-1)/k*k;
				ed=st+k;
			}
		}
		if(x<=ed) {
			cnt++;
		}
	}
	if(cnt>0) ti++;

	printf("%lld",ti);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+100;
LL a[maxn];
LL n,m,k;
map<LL,int>s;

int main(){
	scanf("%lld%lld%lld",&n,&m,&k);
	LL st=1,ed=k,cnt=0,ti=0,x;
	for(int i=1; i<=m; i++){
		scanf("%lld",&x);
		while(ed<x){
			if(cnt){
				st=ed+1;
				ed=ed+cnt;
				cnt=0;
				ti++;
			}
			else {
				st=(x-ed-1)/k*k+ed+1;
				ed=st+k-1;
			}
		}
		if(x<=ed) {
			cnt++;
		}
	}
	if(cnt) ti++;

	printf("%lld",ti);

	return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
template <typename A, typename B> ostream& operator<<(ostream& os, pair<A,B> p) { return os << '{' << p.first << ", " << p.second << '}'; }
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  vector<ll> a(m);
  fo1(i, m)
    cin >> a[i];
  // a[m++] = 2e18;

  sort(all(a)); // acho que nem precisa

  ll s = 0; // shift
  // ll d = 0; // current page delta
  ll ops = 0;
  ll p = 1;
  // fo1(i, m) {
  //   // cout << a[i] << ' ' << a[i]-s << endl;
  //   if (a[i]-s <= k*p) {
  //     d++;
  //   } else {
  //     // cout << a[i] << ' ' << s << ' ' << d << endl;
  //     if (d != 0)
  //       ops++;
  //     s += d;
  //     d = 0;
  //     if (a[i]-s <= k*p)
  //       i--;
  //     else
  //       p++;
  //   }
  // }

  int i = 0;
  while (i < m && k*p <= n) {
    ll d = 0;
    bool picked = false;
    while (i < m && a[i]-s <= k*p) {
      i++;
      d++;
      picked = true;
    }

    if (picked) {
      ops++;
      s += d;
    } else {
      p++;
    }
  }

  cout << ops << endl;
  return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
template <typename A, typename B> ostream& operator<<(ostream& os, pair<A,B> p) { return os << '{' << p.first << ", " << p.second << '}'; }
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  vector<ll> a(m);
  fo1(i, m)
    cin >> a[i];
  // a[m++] = 2e18;

  sort(all(a)); // acho que nem precisa

  ll s = 0; // shift
  // ll d = 0; // current page delta
  ll ops = 0;
  ll p = k*((a[0]-s)/k + 1);
  int i = 0;
  ll d = 0;
  while (i < m) {
    d = 0;
    while (i < m && a[i]-s <= p) {
      i++;
      d++;
    }

    // cout << i << ' ' << a[i] << ' ' << d << endl;
    ops++;
    s += d;
    if (i < m) {
      p = k*((a[i]-s-1)/k + 1);
      // cout << a[i]-s << ' ' << p << endl;
    } else {
      break;
    }
  }

  cout << ops << endl;
  return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
template <typename A, typename B> ostream& operator<<(ostream& os, pair<A,B> p) { return os << '{' << p.first << ", " << p.second << '}'; }
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  ll n; cin >> n;
  int m; cin >> m;
  int k; cin >> k;
  vi a(m);
  fo1(i, m)
    cin >> a[i];

  sort(all(a)); // acho que nem precisa

  int s = 0; // shift
  int d = 0; // current page delta
  int ops = 0;
  int p = 1;
  fo1(i, m) {
    // cout << a[i] << ' ' << a[i]-s << endl;
    if (a[i]-s <= k*p) {
      d++;
    } else {
      if (d != 0)
        ops++;
      s += d;
      d = 0;
      if (a[i]-s <= k*p)
        i--;
      else
        p++;
    }
  }
  cout << ops+1 << endl;
  return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
template <typename A, typename B> ostream& operator<<(ostream& os, pair<A,B> p) { return os << '{' << p.first << ", " << p.second << '}'; }
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  vector<ll> a(m);
  fo1(i, m)
    cin >> a[i];
  // a[m++] = 2e18;

  sort(all(a)); // acho que nem precisa

  ll s = 0; // shift
  // ll d = 0; // current page delta
  ll ops = 0;
  ll p = 1;
  // fo1(i, m) {
  //   // cout << a[i] << ' ' << a[i]-s << endl;
  //   if (a[i]-s <= k*p) {
  //     d++;
  //   } else {
  //     // cout << a[i] << ' ' << s << ' ' << d << endl;
  //     if (d != 0)
  //       ops++;
  //     s += d;
  //     d = 0;
  //     if (a[i]-s <= k*p)
  //       i--;
  //     else
  //       p++;
  //   }
  // }

  int i = 0;
  while (i < m) {
    ll d = 0;
    bool picked = false;
    while (i < m && a[i]-s <= k*p) {
      i++;
      d++;
      picked = true;
    }

    if (picked) {
      ops++;
      s += d;
    } else {
      p++;
    }
  }

  cout << ops << endl;
  return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
template <typename A, typename B> ostream& operator<<(ostream& os, pair<A,B> p) { return os << '{' << p.first << ", " << p.second << '}'; }
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  vector<ll> a(m);
  fo1(i, m)
    cin >> a[i];
  a[m++] = 2e18;

  sort(all(a)); // acho que nem precisa

  ll s = 0; // shift
  // ll d = 0; // current page delta
  ll ops = 0;
  ll p = k;
  // fo1(i, m) {
  //   // cout << a[i] << ' ' << a[i]-s << endl;
  //   if (a[i]-s <= k*p) {
  //     d++;
  //   } else {
  //     // cout << a[i] << ' ' << s << ' ' << d << endl;
  //     if (d != 0)
  //       ops++;
  //     s += d;
  //     d = 0;
  //     if (a[i]-s <= k*p)
  //       i--;
  //     else
  //       p++;
  //   }
  // }

  int i = 0;
  while (i < m) {
    ll d = 0;
    bool picked = false;
    while (i < m && a[i]-s <= p) {
      i++;
      d++;
      picked = true;
    }

    if (picked) {
      ops++;
      s += d;
    } else {
      p = k*((a[i]-s)/k + 1);
    }
  }

  cout << ops-1 << endl;
  return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
template <typename A, typename B> ostream& operator<<(ostream& os, pair<A,B> p) { return os << '{' << p.first << ", " << p.second << '}'; }
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  vector<ll> a(m);
  fo1(i, m)
    cin >> a[i];
  // a[m++] = 2e18;

  sort(all(a)); // acho que nem precisa

  ll s = 0; // shift
  // ll d = 0; // current page delta
  ll ops = 0;
  ll p = k;
  // fo1(i, m) {
  //   // cout << a[i] << ' ' << a[i]-s << endl;
  //   if (a[i]-s <= k*p) {
  //     d++;
  //   } else {
  //     // cout << a[i] << ' ' << s << ' ' << d << endl;
  //     if (d != 0)
  //       ops++;
  //     s += d;
  //     d = 0;
  //     if (a[i]-s <= k*p)
  //       i--;
  //     else
  //       p++;
  //   }
  // }

  int i = 0;
  while (i < m) {
    ll d = 0;
    bool picked = false;
    while (i < m && a[i]-s <= p) {
      i++;
      d++;
      picked = true;
    }

    if (picked) {
      ops++;
      s += d;
    } else {
      p = k*((a[i]-s)/k + 1);
    }
  }

  cout << ops << endl;
  return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
template <typename A, typename B> ostream& operator<<(ostream& os, pair<A,B> p) { return os << '{' << p.first << ", " << p.second << '}'; }
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  vector<ll> a(m);
  fo1(i, m)
    cin >> a[i];
  // a[m++] = 2e18;

  sort(all(a)); // acho que nem precisa

  ll s = 0; // shift
  // ll d = 0; // current page delta
  ll ops = 0;
  ll p = k*((a[0]-s-1)/k + 1);
  int i = 0;
  ll d = 0;
  while (i < m) {
    d = 0;
    while (i < m && a[i]-s <= p) {
      i++;
      d++;
    }

    // cout << i << ' ' << a[i] << ' ' << d << endl;
    ops++;
    s += d;
    if (i < m) {
      p = k*((a[i]-s-1)/k + 1);
      // cout << a[i]-s << ' ' << p << endl;
    } else {
      break;
    }
  }

  cout << ops << endl;
  return 0;
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
template <typename A, typename B> ostream& operator<<(ostream& os, pair<A,B> p) { return os << '{' << p.first << ", " << p.second << '}'; }
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo; const int N = 100005;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  ll n; cin >> n;
  ll m; cin >> m;
  ll k; cin >> k;
  vector<ll> a(m);
  fo1(i, m)
    cin >> a[i];
  // a[m++] = 2e18;

  sort(all(a)); // acho que nem precisa

  ll s = 0; // shift
  ll d = 0; // current page delta
  ll ops = 0;
  ll p = 1;
  fo1(i, m) {
    // cout << a[i] << ' ' << a[i]-s << endl;
    if (a[i]-s <= k*p) {
      d++;
    } else {
      // cout << a[i] << ' ' << s << ' ' << d << endl;
      if (d != 0)
        ops++;
      s += d;
      d = 0;
      if (a[i]-s <= k*p)
        i--;
      else
        p++;
    }
  }

  cout << ops+1 << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){

    int n,m,k;
    long long temp = 0;
    long long p[10010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        divide_point = (p[1]/k+1)*k;
        long long add = 0;
        for(int i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point+=k;
            }

        }

        cout<<cnt<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,k;
    long long temp = 0;
    long long p[100010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        divide_point = (p[1]/k+1)*k;
        long long add = 0;
        for(long long i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point = divide_point + ((p[i]-divide_point-1)/k+1ll)*k;

            }

        }
        cout<<cnt<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){

    long long n,m,k;
    long long temp = 0;
    long long p[10010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        divide_point = (p[1]/k+1)*k;
        long long add = 0;
        for(long long i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point = (p[i]/k+1)*k;
            }

        }

        cout<<cnt<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,k;
    long long temp = 0;
    long long p[100010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        divide_point = ((p[1]-1)/k+1)*k;
        long long add = 0;
        for(long long i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point = divide_point + ((p[i]-divide_point-1)/k+1ll)*k;

            }

        }
        cout<<cnt<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){

    int n,m,k;
    long long temp = 0;
    long long p[10010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        long long add = 0;
        for(int i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point+=k;
            }

        }

        cout<<cnt<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,k;
    long long temp = 0;
    long long p[10010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        divide_point = (p[1]/k+1)*k;
        long long add = 0;
        for(long long i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point = divide_point + ((p[i]-divide_point)/k+1ll)*k;
            }

        }
        cout<<cnt<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,k;
    long long temp = 0;
    long long p[100010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        divide_point = (p[1]/k+1)*k;
        long long add = 0;
        for(long long i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point = divide_point + ((p[i]-divide_point)/k+1ll)*k;
            }

        }
        cout<<cnt<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){

    long long n,m,k;
    long long temp = 0;
    long long p[10010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        divide_point = (p[1]/k+1)*k;
        long long add = 0;
        for(long long i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point+=k;
            }

        }

        cout<<cnt<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,k;
    long long temp = 0;
    long long p[10010];
    memset(p,0,sizeof(p));
    while(cin>>n>>m>>k){
        long long cnt = 0;
        long long divide_point = k;
        for(int i=1; i<=m; i++){
            scanf("%lld",&p[i]);
        }
        divide_point = (p[1]/k+1)*k;
        long long add = 0;
        for(long long i=1; i<=m; ){
            add = 0;
            while(p[i]<=divide_point){
                i++;
                add++;
            }
            // cout<<cnt<<"---"<<divide_point<<endl;
            if(add!=0){
                divide_point+=add;
                cnt++;
            }
            else{
                divide_point = ((p[i]-divide_point)/k+1)*k;
            }

        }
        cout<<cnt<<endl;
    }

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
ll n,m,k,p[100005],ste=0,t=0,o=0;
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for(ll i=0;i<m;i++)
    {
        scanf("%lld",&p[i]);
    }
    sort(p,p+m,cmp);
    o=k;
    while(m>0)
    {
        ll flag=0;
        while(p[m-1]-t<=o&&m>0)
        {
            //cout<<p[m-1]<<" out"<<endl;
            m--;
            flag++;
        }
        if(flag)
        {
            t+=flag;
            ste++;
        }
        else
        {

            o=((p[m-1]-t)/k+1)*k;
            if((p[m-1]-t)/k*k==p[m-1]-t)
                o-=k;
        }
        //cout<<"-----------"<<endl;
    }
    printf("%lld\n",ste);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
ll n,m,k,p[100005],ste=0,t=0,o=0;
bool cmp(int a,int b)
{
    return a>b;
}
void init()
{
    ll flag=0;
    while(p[m-1]-t<=k&&m>0)
    {
        m--;
        flag++;
    }
    if(flag)
    {
        t+=flag;
        ste++;
    }
    else
    {
        k+=k;
    }
}
int main()
{
    cin>>n>>m>>k;
    for(int i=0;i<m;i++)
    {
        cin>>p[i];
    }
    sort(p,p+m,cmp);
    while(k<=n)
    {
        init();
    }
    cout<<ste<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
ll n,m,k,p[100005],ste=0,t=0,o=0;
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for(ll i=0;i<m;i++)
    {
        scanf("%lld",&p[i]);
    }
    sort(p,p+m,cmp);
    o=k;
    while(m>0)
    {
        ll flag=0;
        while(p[m-1]-t<=o&&m>0)
        {
            m--;
            flag++;
        }
        if(flag)
        {
            t+=flag;
            ste++;
        }
        else
        {
            o=(((p[m-1])-t)/k+1)*k;
        }
    }
    printf("%lld\n",ste);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
ll n,m,k,p[100005],ste=0,t=0,o=0;
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for(ll i=0;i<m;i++)
    {
        scanf("%lld",&p[i]);
    }
    sort(p,p+m,cmp);
    o=k;
    while(m>0)
    {
        ll flag=0;
        while(p[m-1]-t<=o&&m>0)
        {
            m--;
            flag++;
        }
        if(flag)
        {
            t+=flag;
            ste++;
        }
        else
        {
            o=((p[m-1]-t)/k+1)*k;
        }
    }
    printf("%lld\n",ste);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
ll n,m,k,p[100005],ste=0,t=0,o=0;
bool cmp(int a,int b)
{
    return a>b;
}
void init()
{
    ll flag=0;
    while(p[m-1]-t<=k&&m>0)
    {
        m--;
        flag++;
    }
    if(flag)
    {
        t+=flag;
        ste++;
    }
    else
    {
        k+=k;
    }
}
int main()
{
    cin>>n>>m>>k;
    for(ll i=0;i<m;i++)
    {
        cin>>p[i];
    }
    sort(p,p+m,cmp);
    while(k<=n)
    {
        init();
        if(m<0)
            break;
    }
    cout<<ste<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
ll n,m,k,p[100005],ste=0,t=0,o=0;
bool cmp(ll a,ll b)
{
    return a>b;
}
int main()
{
    scanf("%lld%lld%lld",&n,&m,&k);
    for(ll i=0;i<m;i++)
    {
        scanf("%lld",&p[i]);
    }
    sort(p,p+m,cmp);
    o=k;
    while(m>0)
    {
        ll flag=0;
        while(p[m-1]-t<=o&&m>0)
        {
            m--;
            flag++;
        }
        if(flag)
        {
            t+=flag;
            ste++;
        }
        else
        {
            o=((p[m-1])/k+1)*k;
        }
    }
    printf("%lld\n",ste);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    ll n,m,k,p[100005],x,o=0,set=0,t=0;
    cin>>n>>m>>k;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        if(x<=n/2)
        {
            set=1;
            t++;
        }
        else
        {
            p[o++]=x;
        }
    }
    sort(p,p+o,cmp);
    while(o>0)
    {
        int flag=0;
        while(p[o-1]-t<=n/2)
        {
            o--;
            flag++;
        }
        if(flag)
        {
            t+=flag;
            set++;
        }
        else
        {
            if(o>0)
            {
                set++;
                break;
            }
        }
    }
    cout<<set<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
const int MOD=1000000007;
typedef long long ll;
ll n,m,k,p[100005],ste=0,t=0,o=0;
bool cmp(int a,int b)
{
    return a>b;
}
void init()
{
    ll flag=0;
    while(p[m-1]-t<=o&&m>0)
    {
        m--;
        flag++;
    }
    if(flag)
    {
        t+=flag;
        ste++;
    }
    else
    {
        o+=k;
    }
}
int main()
{
    cin>>n>>m>>k;
    for(ll i=0;i<m;i++)
    {
        cin>>p[i];
    }
    sort(p,p+m,cmp);
    o=k;
    while(o<=n)
    {
        init();
        if(m<0)
            break;
    }
    cout<<ste<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;
#define int long long

 main(){
    LL n,m,k,i; cin>>n>>m>>k;
     vector<LL>ar;
      for(int j=0;j<m;j++){
    LL x; cin>>x;--x; ar.push_back(x);

      }
LL ans=0;
     for(int i=0;i<m;i++){
            int j=i;
        while((ar[j]-i)/k == (ar[i]-i)/k) j++;
        i = j-1;
        ans++;
     }
     cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;
#define int long long

int main(){
    LL n,m,k,i; cin>>n>>m>>k;
     vector<LL>ar;
      for(int j=0;j<m;j++){
    LL x; cin>>x;--x; ar.push_back(x);

      }
LL ans=0;
     for(int i=0;i<m;i++){
            int j=i;
        while((ar[j]-i)/k == (ar[i]-i)/k) j++;
        i = j-1;
        ans++;
     }
     cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    int n,m,k,i; cin>>n>>m>>k;
     cin>>i; i--;
     int p = i/k, ctr=0,ans=0, spctr=1;

     for(int j=1;j<m;j++){
         cin>>i; i--;
         if(p==(i-ctr)/k)   spctr++;
         else {
             ans++;
             ctr=spctr;
             p=(i-ctr)/k;
         }
     }

     cout<<ans+1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, m, k, ans=0, a[100005], kai;
main()
{
	if(fopen("trash.inp", "r"))
		freopen("trash.inp", "r", stdin), freopen("trash.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1; i<=m; i++)cin>>a[i];
	for(int i=1; i<=m; i++)
	{
		int j=i;
		while((a[i]-i)/k==(a[j]-i)/k)
			{
			//	cerr<<a[i]<<" "<<a[j]<<'\n';
				j++;
			}
		//cerr<<i<<" "<<j<<endl;
		i=j-1;

		ans++;
	}
	cout<<ans;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    LL n,m,k,i; cin>>n>>m>>k;
     vector<int>ar;
      for(int j=0;j<m;j++){
    LL x; cin>>x;--x; ar.push_back(x);

      }
int ans=0;
     for(int i=0;i<m;i++){
            int j=i;
        while((ar[j]-i)/k == (ar[i]-i)/k) j++;
        i = j-1;
        ans++;
     }
     cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    LL n,m,k,i; cin>>n>>m>>k;
     vector<int>ar;
      for(int j=0;j<m;j++){
    LL x; cin>>x;--x; ar.push_back(x);

      }
LL ans=0;
     for(int i=0;i<m;i++){
            LL j=i;
        while((ar[j]-i)/k == (ar[i]-i)/k) j++;
        i = j-1;
        ans++;
     }
     cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    int n,m,k,i; cin>>n>>m>>k;
     vector<int>ar;
      for(int j=0;j<m;j++){
    int x; cin>>x;--x; ar.push_back(x);

      }
     int p = ar[0]/k, ctr=0,ans=0, spctr=1;bool ch;

     for(int j=1;j<m;j++){

         if(p==(ar[j]-ctr)/k) {  spctr++;ch = true; }
         else {
             ans++;
             ctr=spctr;
             p=(ar[j]-ctr)/k;j--;
             ch=false;
         }
     }
   if(ch)
     cout<<ans+1;
    else cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    LL n,m,k,i; cin>>n>>m>>k;
     vector<LL>ar;
      for(int j=0;j<m;j++){
    LL x; cin>>x;--x; ar.push_back(x);

      }
LL ans=0;
     for(int i=0;i<m;i++){
            int j=i;
        while((ar[j]-i)/k == (ar[i]-i)/k) j++;
        i = j-1;
        ans++;
     }
     cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    LL n,m,k,i; cin>>n>>m>>k;
     vector<int>ar;
      for(int j=0;j<m;j++){
    LL x; cin>>x;--x; ar.push_back(x);

      }
     LL p = ar[0]/k, ctr=0,ans=0, spctr=1;bool ch;

     for(int j=1;j<m;j++){

         if(p==(ar[j]-ctr)/k) {  spctr++;ch = true; }
         else {
             ans++;
             ctr=spctr;
             p=(ar[j]-ctr)/k;j--;
             ch=false;
         }
     }
   if(ch)
     cout<<ans+1;
    else cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    int n,m,k,i; cin>>n>>m>>k;
     vector<int>ar;
      for(int j=0;j<m;j++){
    int x; cin>>x;--x; ar.push_back(x);

      }
     int p = ar[0]/k, ctr=0,ans=0, spctr=1;bool ch;

     for(int j=1;j<=m;j++){

         if(p==(ar[j]-ctr)/k) {  spctr++; }
         else {
             ans++;
             ctr=spctr;
             p=(ar[j]-ctr)/k;j--;
         }
     }

     cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    LL n,m,k,i; cin>>n>>m>>k;
     vector<int>ar;
      for(int j=0;j<m;j++){
    LL x; cin>>x;--x; ar.push_back(x);

      }
     LL p = ar[0]/k, ctr=0,ans=0, spctr=1;bool ch;

     for(int j=1;j<m;j++){

         if(p==(ar[j]-ctr)/k) {  spctr++;ch = true; }
         else {
             ans++;
             ctr=spctr;spctr++;
             p=(ar[j]-ctr)/k;j--;
             ch=false;
         }
     }
   if(ch)
     cout<<ans+1;
    else cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define N 1000000007
using namespace std;

int main(){
    LL n,m,k,i; cin>>n>>m>>k;
     vector<LL>ar;
      for(LL j=0;j<m;j++){
    LL x; cin>>x;--x; ar.push_back(x);

      }
     LL p = ar[0]/k, ctr=0,ans=0, spctr=1;bool ch;

     for(LL j=1;j<m;j++){

         if(p==(ar[j]-ctr)/k) {  spctr++;ch = true; }
         else {
             ans++;
             ctr=spctr;
             p=(ar[j]-ctr)/k;j--;
             ch=false;
         }
     }
   if(ch)
     cout<<ans+1;
    else cout<<ans;
    return 0;
}


#include<iostream>
using namespace std;
long long int n, m, k;
long long int pos[100000];

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		scanf("%d", &pos[i]);

	long long int ans = 0;
	long long int right = k;
	long long int erase_num = 0;

	while (1)
	{
		if (erase_num == m)break;
		if (pos[erase_num]-erase_num>right)
		{
			right = right*(pos[erase_num] / k) + k;
			continue;
		}
		int cnt = 0;
		for (int i = erase_num; i < m; ++i)
		{
			if (pos[i] - erase_num <= right)
				cnt++;
			else
				break;
		}
		erase_num += cnt;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
using namespace std;
long long int n, m, k;
int pos[100000];

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		scanf("%d", &pos[i]);

	long long int ans = 0;
	int right = k;
	int erase_num = 0;

	while (1)
	{
		if (erase_num == m)break;
		if (pos[erase_num]-erase_num>right)
		{
			right += k;
			continue;
		}
		int cnt = 0;
		for (int i = erase_num; i < m; ++i)
		{
			if (pos[i] - erase_num <= right)
				cnt++;
			else
				break;
		}
		erase_num += cnt;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
long long int n, m, k;
long long int pos[100000];

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		scanf("%d", &pos[i]);

	sort(pos, pos + m);

	long long int ans = 0;
	long long int right = k;
	long long int erase_num = 0;

	while (1)
	{
		if (erase_num == m)break;
		int cnt = 0;
		for (int i = erase_num; i < m; ++i)
		{
			if (pos[i] - erase_num <= right)
				cnt++;
			else
				break;
		}
		erase_num += cnt;
		if (cnt==0)
		{
			right = k*((pos[erase_num]-erase_num-1) / k)+k;
			continue;
		}
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
using namespace std;
long long int n, m, k;
int pos[100000];

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		scanf("%d", &pos[i]);

	long long int ans = 0;
	long long int right = k;
	int erase_num = 0;

	while (1)
	{
		if (erase_num == m)break;
		if (pos[erase_num]-erase_num>right)
		{
			right += k;
			continue;
		}
		int cnt = 0;
		for (int i = erase_num; i < m; ++i)
		{
			if (pos[i] - erase_num <= right)
				cnt++;
			else
				break;
		}
		erase_num += cnt;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
long long int n, m, k;
long long int pos[100000];

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		cin >> pos[i];

	sort(pos, pos + m);

	long long int ans = 0;
	long long int right = k;
	long long int erase_num = 0;

	while (1)
	{
		if (erase_num == m)break;
		int cnt = 0;
		for (int i = erase_num; i < m; ++i)
		{
			if (pos[i] - erase_num <= right)
				cnt++;
			else
				break;
		}
		erase_num += cnt;
		if (cnt==0)
		{
			right = k*((pos[erase_num]-erase_num-1) / k)+k;
			continue;
		}
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
using namespace std;
long long int n, m, k;
long long int pos[100000];

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		scanf("%d", &pos[i]);

	long long int ans = 0;
	long long int right = k;
	long long int erase_num = 0;

	while (1)
	{
		if (erase_num == m)break;
		int cnt = 0;
		for (int i = erase_num; i < m; ++i)
		{
			if (pos[i] - erase_num <= right)
				cnt++;
			else
				break;
		}
		erase_num += cnt;
		if (cnt==0)
		{
			right = k*((pos[erase_num]-erase_num-1) / k)+k;
			continue;
		}
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include<iostream>
using namespace std;
long long int n, m, k;
int pos[100000];

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		cin >> pos[i];

	long long int ans = 0;
	int right = k;
	int erase_num = 0;

	while (1)
	{
		if (erase_num == m)break;

		int cnt = 0;
		for (int i = erase_num; i < m; ++i)
		{
			if (pos[i] - erase_num <= right)
				cnt++;
			else
				break;
		}
		erase_num += cnt;
		if (cnt == 0)
		{
			right += k;
			continue;
		}
		ans++;
	}
	cout << ans << '\n';
	return 0;
}


#include<iostream>
using namespace std;
long long int n, m, k;
long long int pos[100000];

int main()
{
	cin >> n >> m >> k;
	for (int i = 0; i < m; ++i)
		scanf("%d", &pos[i]);

	long long int ans = 0;
	long long int right = k;
	long long int erase_num = 0;

	while (1)
	{
		if (erase_num == m)break;
		if (pos[erase_num]-erase_num>right)
		{
			right += k;
			continue;
		}
		int cnt = 0;
		for (int i = erase_num; i < m; ++i)
		{
			if (pos[i] - erase_num <= right)
				cnt++;
			else
				break;
		}
		erase_num += cnt;
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
#define fore(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
typedef long long ll;
vector<ll>v;
ll n,m,k;

int main(){
    cin>>n>>m>>k;
    fore(i,1,m){ll x;scanf("%lld",&x);v.push_back(x);}
    ll now=0,ans=0;
    while(v.size()){
        ll str=(v[0]-now-1)/k;
        int i=0;
        while(i<v.size() && (v[i]-now-1)/k==str) i++;
        fore(j,0,i-1) v.erase(v.begin());
        ans++;
        now+=i;
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
#define fore(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
typedef long long ll;
vector<ll>v;
ll n,m,k;

int main(){
    cin>>n>>m>>k;
    fore(i,1,m){ll x;scanf("%lld",&x);v.push_back(x);}
    ll now=0,ans=0;
    for(ll i=k;;){
        bool flag=true;
        while(flag){
            int j=0;
            while(j<(int)v.size() && v[j]-now<=i) j++;
            fore(k,0,j-1) {/* cout<<v[0]-now<<" "; */v.erase(v.begin());}
            now+=j;
            /* cout<<"\n"; */
            if(j!=0) flag=true,ans++;
            else flag=false;
        }
        if(!v.size()) break;
        else i=((v[0]-now+k-1)/k)*k;
    }
    cout<<ans;
    return 0;
}


#include <iostream>
#include <vector>
using namespace std;
#define fore(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
typedef long long ll;
vector<ll>v;
ll n,m,k;

int main(){
    cin>>n>>m>>k;
    fore(i,1,m){ll x;scanf("%lld",&x);v.push_back(x);}
    ll now=0,ans=0;
    for(ll i=k;i<=n;i+=k){
        bool flag=true;
        while(flag){
            int j=0;
            while(j<(int)v.size() && v[j]-now<=i) j++;
            fore(k,0,j-1) {/* cout<<v[0]-now<<" "; */v.erase(v.begin());}
            now+=j;
            /* cout<<"\n"; */
            if(j!=0) flag=true,ans++;
            else flag=false;
        }
        i+=((v[0]-now-k)/k)*k;
    }
    cout<<ans;
    return 0;
}