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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define all(x) (x).begin(), (x).end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n, h, m, k;
	cin >> n >> h >> m >> k;
	vector<ii> tr;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (b >= m / 2) {
			b = b - m / 2;
			tr.pb({b, i + 1});
			tr.pb({b - m / 2, i + 1});
		} else {
			tr.pb({b, i + 1});
		}
		//tr[i + n] = {b + m, i + 1};
	}
	tr.pb({m / 2 + m - 1, -1});
	sort(all(tr));
	int indL = 0, indR = 0, resL = 0, resR = n;
	while (tr[indR].fi < 0) {
		indR++;
	}
	for (int i = indR; i < tr.size(); i++) {
		while (indL < indR && tr[indL].fi + k <= tr[indR].fi) {
			indL++;
		}
		if (indR - indL < resR - resL) {
			resR = indR;
			resL = indL;
		}
	}
	cout << resR - resL << " " << tr[resR].fi << endl;
	vector<int> res;
	for (int i = resL; i < resR; i++) {
		res.pb(tr[i].se);
	}
	sort(all(res));
	for (int i = 0; i < res.size(); i++) {
		cout << res[i] << " ";
	}
	cout << endl;
}


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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define all(x) (x).begin(), (x).end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n, h, m, k;
	cin >> n >> h >> m >> k;
	vector<ii> tr(2 * n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		tr[i] = {b, i + 1};
		tr[i + n] = {b + m, i + 1};
	}
	sort(all(tr));
	int min = n;
	set<int> act, res;
	int indexU1 = 0;
	int indexD1 = 0;
	int indexU2 = 0;
	int indexD2 = 0;
	for (int i = 0; i < 2 * n; i++) {
		if (tr[i].fi >= m / 2) {
			indexU2 = i;
			indexD2 = i;
			break;
		}
	}
	int resM = 0;
	for (int i = 0; i < m / 2; i++) {
		while (indexU1 < 2 * n && tr[indexU1].fi < k + i) {
			act.insert(tr[indexU1].se);
			indexU1++;
		}
		while (indexD1 < 2 * n && tr[indexD1].fi <= i) {
			act.erase(tr[indexD1].se);
			indexD1++;
		}
		while (indexU2 < 2 * n && tr[indexU2].fi < k + i + m / 2) {
			act.insert(tr[indexU2].se);
			indexU2++;
		}
		while (indexD2 < 2 * n && tr[indexD2].fi <= i + m / 2) {
			act.erase(tr[indexD2].se);
			indexD2++;
		}
		if (act.size() < min) {
			res = act;
			min = act.size();
			resM = i + k;
		}
	}
	cout << min << " " << resM << endl;
	for (auto i = res.begin(); i != res.end(); i++) {
		cout << *i << " ";
	}
	cout << endl;
}


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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define all(x) (x).begin(), (x).end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n, h, m, k;
	cin >> n >> h >> m >> k;
	vector<ii> tr;
	bool last = false;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (b == m / 2 - 1 || b == m - 1) {
			last = true;
		}
		if (b >= m / 2) {
			b = b - m / 2;
			tr.pb({b, i + 1});
			tr.pb({b - m / 2, i + 1});
		} else {
			tr.pb({b, i + 1});
			tr.pb({b - m / 2, i + 1});
		}
		//tr[i + n] = {b + m, i + 1};
	}
	if (!last) {
		tr.pb({m / 2 - 1, -1});
	}
	sort(all(tr));
	int indL = 0, indR = 0, resL = 0, resR = n;
	debug() << tr;
	while (tr[indR].fi < 0) {
		indR++;
	}
	for (int i = indR; i < tr.size(); i++) {
		while (indL < indR && tr[indL].fi + k <= tr[indR].fi) {
			indL++;
		}
		if (indR - indL < resR - resL) {
			resR = indR;
			resL = indL;
		}
	}
	cout << resR - resL << " " << tr[resR].fi << endl;
	vector<int> res;
	for (int i = resL; i < resR; i++) {
		res.pb(tr[i].se);
	}
	sort(all(res));
	for (int i = 0; i < res.size(); i++) {
		cout << res[i] << " ";
	}
	cout << endl;
}


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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define all(x) (x).begin(), (x).end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n, h, m, k;
	cin >> n >> h >> m >> k;
	vector<ii> tr;
	bool last = false;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (b == m / 2 - 1 || b == m - 1) {
			last = true;
		}
		if (b >= m / 2) {
			b = b - m / 2;
			tr.pb({b, i + 1});
			tr.pb({b - m / 2, i + 1});
		} else {
			tr.pb({b, i + 1});
			tr.pb({b - m / 2, i + 1});
		}
		//tr[i + n] = {b + m, i + 1};
	}
	if (!last) {
		tr.pb({m / 2 - 1, -1});
	}
	sort(all(tr));
	int indL = 0, indR = 0, resL = 0, resR = n;
	debug() << tr;
	while (tr[indR].fi < 0) {
		indR++;
	}
	bool done = false;
	for (int i = indR; i < tr.size(); i++) {
		while (indL < indR && tr[indL].fi + k <= tr[indR].fi) {
			indL++;
		}
		if (indR - indL < resR - resL) {
			resR = indR;
			resL = indL;
		}
		if (!done && tr[indR].fi >= 0 && k == 40362) {
			cout << indR << " " << indL << endl;
			done = true;
		}
	}
	cout << resR - resL << " " << tr[resR].fi << endl;
	vector<int> res;
	for (int i = resL; i < resR; i++) {
		res.pb(tr[i].se);
	}
	sort(all(res));
	for (int i = 0; i < res.size(); i++) {
		cout << res[i] << " ";
	}
	cout << endl;
}


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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define all(x) (x).begin(), (x).end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n, h, m, k;
	cin >> n >> h >> m >> k;
	vector<ii> tr(n * 2 + 1);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (b >= m / 2) {
			b = b - m / 2;
		}
		tr[i] = {b, i + 1};
		tr[i + n] = {b + m, i + 1};
	}
	tr[n * 2] = {m / 2 + m, -1};
	sort(all(tr));
	int indL = 0, indR = n, resL = 0, resR = n;
	for (int i = indR; i <= 2 * n; i++) {
		while (indL < indR && tr[indL].fi + k <= tr[indR].fi) {
			indL++;
		}
		if (indR - indL < resR - resL) {
			resR = indR;
			resL = indL;
		}
	}
	cout << resR - resL << " " << tr[resR].fi - m << endl;
	vector<int> res;
	for (int i = resL; i < resR; i++) {
		res.pb(tr[i].se);
	}
	sort(all(res));
	for (int i = 0; i < res.size(); i++) {
		cout << res[i] << " ";
	}
	cout << endl;
}


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

#define ll long long
typedef pair <int, int> ii;
typedef pair <ll, int> lli;
#define ar array
#define pb push_back
#define fi first
#define se second
#define sz size
#define mp make_pair
#define all(x) (x).begin(), (x).end()

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T>
auto lbf(const std::set<std::pair<T, T>>& s, T first)
{
   static constexpr T min = std::numeric_limits<T>::min();

   return s.lower_bound({first, min});
}

int MOD = 1000000007;

ll pw(ll n, ll k) {
	ll r = 1;
	for(; k; k >>= 1) {
		if(k&1) r = r * n % MOD;
		n = n * n % MOD;
	}
	return r;
}
ll inv(ll n) { return pw(n, MOD-2); }

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int n, h, m, k;
	cin >> n >> h >> m >> k;
	vector<ii> tr(n * 2);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (b >= m / 2) {
			b = b - m / 2;
		}
		tr[i] = {b, i + 1};
		tr[i + n] = {b + m, i + 1};
	}
	sort(all(tr));
	if (tr[n - 1].fi + k < m / 2) {
		cout << 0 << " " << m / 2 - 1 << endl << endl;
		return 0;
	}
	int indL = 0, indR = n, resL = 0, resR = n;
	for (int i = indR; i < 2 * n; i++) {
		while (indL < indR && tr[indL].fi + k <= tr[indR].fi) {
			indL++;
		}
		if (indR - indL < resR - resL) {
			resR = indR;
			resL = indL;
		}
	}
	cout << resR - resL << " " << tr[resR].fi - m << endl;
	vector<int> res;
	for (int i = resL; i < resR; i++) {
		res.pb(tr[i].se);
	}
	sort(all(res));
	for (int i = 0; i < res.size(); i++) {
		cout << res[i] << " ";
	}
	cout << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef double db;
#define ls(x) ((x)<<1)
#define rs(x) ((x)<<1|1)
#define low(x) ((x)&-(x))
#define all(x) x.begin(),x.end()
#define mp make_pair
#define X first
#define Y second
#ifdef _DEBUG
	const int N=1e6+10;
#else
	const int N=1e6+10;
#endif
const ll mod=1e9+7;
template<typename T> inline T gcd(T a,T b){return !b?a:gcd(b,a%b);}
template<typename T> inline T q_pow(T a,T x){T ans=1,tmp=a;while(x){if(x&1)(ans*=tmp)%=mod;(tmp*=tmp)%=mod;x>>=1;}return ans;}
template<typename T> inline void re(T &N){int f=1;char c;while((c=getchar())< '0'||c> '9')if(c=='-')f=-1;N=c-'0';while((c=getchar())>='0'&&c<='9')N=N*10+c-'0';N*=f;}
int m,n,t=1,st,en,k;
int a[N],d[N],cd;
int c[N];

int main()
{
	// freopen("data.txt","r",stdin);
	// freopen("out1.txt","w",stdout);
	re(n);re(m);re(m);re(k);
	m/=2;d[++d[0]]=0;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		re(x);re(y);
		a[i]=y%m;
		d[++d[0]]=a[i];d[++d[0]]=a[i]+m;
		if(a[i])d[++d[0]]=a[i]-1;d[++d[0]]=a[i]+m-1;
	}
	sort(d+1,d+d[0]+1);d[0]=unique(d+1,d+d[0]+1)-d-1;
	for(int i=1;i<=n;i++)
	{
		{
			int pos=lower_bound(d+1,d+d[0]+1,a[i])-d;
			c[pos]++;
		}
		{
			int pos=lower_bound(d+1,d+d[0]+1,a[i]+m)-d;
			c[pos]++;
		}
	}
	pi ans={1e9,0};
	int l=1,r=0,now=0;
	cd=d[0];d[0]=0;
	while(1)
	{
		now+=c[++r];
		if(d[r]-d[l]>=k)break;
	}
	ans=min(ans,{now-c[l]-c[r],d[r]});
	for(;r<=cd;r++)
	{
		now+=c[r];
		while(1)
		{
			int _l=l+1;
			if(d[r]-d[_l]< k)break;
			now-=c[l++];
			ans=min(ans,{now-c[l]-c[r],d[r]});
		}
	}
	ans.Y%=m;
	printf("%d %d\n",ans.X,ans.Y);
	int c=0;
	for(int i=1;i<=n;i++)
		if((a[i]> ans.Y-k&&a[i]< ans.Y)||(a[i]> ans.Y+m-k&&a[i]< ans.Y+m)||(a[i]> ans.Y-m-k&&a[i]< ans.Y-m))
			printf("%d ",i),c++;
	// puts("");
	// cerr<<c<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef double db;
#define ls(x) ((x)<<1)
#define rs(x) ((x)<<1|1)
#define low(x) ((x)&-(x))
#define all(x) x.begin(),x.end()
#define mp make_pair
#define X first
#define Y second
#ifdef _DEBUG
	const int N=1e6+10;
#else
	const int N=1e6+10;
#endif
const ll mod=1e9+7;
template<typename T> inline T gcd(T a,T b){return !b?a:gcd(b,a%b);}
template<typename T> inline T q_pow(T a,T x){T ans=1,tmp=a;while(x){if(x&1)(ans*=tmp)%=mod;(tmp*=tmp)%=mod;x>>=1;}return ans;}
template<typename T> inline void re(T &N){int f=1;char c;while((c=getchar())< '0'||c> '9')if(c=='-')f=-1;N=c-'0';while((c=getchar())>='0'&&c<='9')N=N*10+c-'0';N*=f;}
int m,n,t=1,st,en,k;
int a[N],d[N],cd;
int c[N];

int main()
{
	// freopen("data.txt","r",stdin);
	// freopen("out1.txt","w",stdout);
	re(n);re(m);re(m);re(k);
	m/=2;d[++d[0]]=0;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		re(x);re(y);
		a[i]=y%m;
		d[++d[0]]=a[i];d[++d[0]]=a[i]+m;
		if(a[i])d[++d[0]]=a[i]-1;d[++d[0]]=a[i]+m-1;
	}
	sort(d+1,d+d[0]+1);d[0]=unique(d+1,d+d[0]+1)-d-1;
	for(int i=1;i<=n;i++)
	{
		{
			int pos=lower_bound(d+1,d+d[0]+1,a[i])-d;
			c[pos]++;
		}
		{
			int pos=lower_bound(d+1,d+d[0]+1,a[i]+m)-d;
			c[pos]++;
		}
	}
	pi ans={1e9,0};
	int l=1,r=0,now=0;
	cd=d[0];d[0]=0;
	while(1)
	{
		now+=c[++r];
		if(d[r]-d[l]>=k)break;
	}
	ans=min(ans,{now-c[l]-c[r],d[r]});
	for(;r<=cd;r++)
	{
		now+=c[r];
		while(1)
		{
			int _l=l+1;
			if(d[r]-d[_l]< k)break;
			now-=c[l++];
			ans=min(ans,{now-c[l]-c[r],d[r]});
		}
	}
	ans.Y%=m;
	printf("%d %d\n",ans.X,ans.Y);
	int c=0;
	for(int i=1;i<=n;i++)
		if((a[i]> ans.Y-k&&a[i]< ans.Y)||(a[i]> ans.Y+m-k&&a[i]< ans.Y+m)||(a[i]> ans.Y-m-k&&a[i]< ans.Y-m))
			c++;
	if(c!=ans.X)return printf("%d\n",c),0;
	for(int i=1;i<=n;i++)
		if((a[i]> ans.Y-k&&a[i]< ans.Y)||(a[i]> ans.Y+m-k&&a[i]< ans.Y+m)||(a[i]> ans.Y-m-k&&a[i]< ans.Y-m))
			printf("%d ",i);
	puts("");
	// cerr<<c<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef double db;
#define ls(x) ((x)<<1)
#define rs(x) ((x)<<1|1)
#define low(x) ((x)&-(x))
#define all(x) x.begin(),x.end()
#define mp make_pair
#define X first
#define Y second
#ifdef _DEBUG
	const int N=1e6+10;
#else
	const int N=1e6+10;
#endif
const ll mod=1e9+7;
template<typename T> inline T gcd(T a,T b){return !b?a:gcd(b,a%b);}
template<typename T> inline T q_pow(T a,T x){T ans=1,tmp=a;while(x){if(x&1)(ans*=tmp)%=mod;(tmp*=tmp)%=mod;x>>=1;}return ans;}
template<typename T> inline void re(T &N){int f=1;char c;while((c=getchar())< '0'||c> '9')if(c=='-')f=-1;N=c-'0';while((c=getchar())>='0'&&c<='9')N=N*10+c-'0';N*=f;}
int m,n,t=1,st,en,k;
int a[N],d[N],cd;
int c[N];

int main()
{
	// freopen("data.txt","r",stdin);
	re(n);re(m);re(m);re(k);
	m/=2;d[++d[0]]=0;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		re(x);re(y);
		a[i]=y%m;
		d[++d[0]]=a[i];d[++d[0]]=a[i]+m;
		if(a[i])d[++d[0]]=a[i]-1;d[++d[0]]=a[i]+m-1;
	}
	sort(d+1,d+d[0]+1);d[0]=unique(d+1,d+d[0]+1)-d-1;
	for(int i=1;i<=n;i++)
	{
		{
			int pos=lower_bound(d+1,d+d[0]+1,a[i])-d;
			c[pos]++;
		}
		{
			int pos=lower_bound(d+1,d+d[0]+1,a[i]+m)-d;
			c[pos]++;
		}
	}
	pi ans={1e9,0};
	int l=1,r=0,now=0;
	cd=d[0];d[0]=0;
	while(1)
	{
		now+=c[++r];
		if(d[r]-d[l]>=k)break;
	}
	ans=min(ans,{now-c[l]-c[r],d[r]});
	for(;r<=cd;r++)
	{
		now+=c[r];
		while(1)
		{
			int _l=l+1;
			if(d[r]-d[_l]< k)break;
			now-=c[l++];
			ans=min(ans,{now-c[l]-c[r],d[r]});
		}
	}
	ans.Y%=m;
	printf("%d %d\n",ans.X,ans.Y);
	for(int i=1;i<=n;i++)
		if((a[i]> ans.Y-k&&a[i]< ans.Y)||(a[i]> ans.Y+m-k&&a[i]< ans.Y+m)||(a[i]> ans.Y-m-k&&a[i]< ans.Y-m))
			printf("%d ",i);
	puts("");
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef double db;
#define ls(x) ((x)<<1)
#define rs(x) ((x)<<1|1)
#define low(x) ((x)&-(x))
#define all(x) x.begin(),x.end()
#define mp make_pair
#define X first
#define Y second
#ifdef _DEBUG
	const int N=1e3+10;
#else
	const int N=1e6+10;
#endif
const ll mod=1e9+7;
template<typename T> inline T gcd(T a,T b){return !b?a:gcd(b,a%b);}
template<typename T> inline T q_pow(T a,T x){T ans=1,tmp=a;while(x){if(x&1)(ans*=tmp)%=mod;(tmp*=tmp)%=mod;x>>=1;}return ans;}
template<typename T> inline void re(T &N){int f=1;char c;while((c=getchar())< '0'||c> '9')if(c=='-')f=-1;N=c-'0';while((c=getchar())>='0'&&c<='9')N=N*10+c-'0';N*=f;}
int m,n,t=1,st,en,k;
int a[N],d[N],cd;
int c[N];

int main()
{
	// freopen("data.txt","r",stdin);
	re(n);re(m);re(m);re(k);
	m/=2;d[++d[0]]=0;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		re(x);re(y);
		a[i]=y%m;
		d[++d[0]]=a[i];d[++d[0]]=a[i]+m;
		if(a[i])d[++d[0]]=a[i]-1;d[++d[0]]=a[i]+m-1;
	}
	sort(d+1,d+d[0]+1);d[0]=unique(d+1,d+d[0]+1)-d-1;
	for(int i=1;i<=n;i++)
	{
		{
			int pos=lower_bound(d+1,d+d[0]+1,a[i])-d;
			c[pos]++;
		}
		{
			int pos=lower_bound(d+1,d+d[0]+1,a[i]+m)-d;
			c[pos]++;
		}
	}
	pi ans={1e9,0};
	int l=1,r=0,now=0;
	cd=d[0];d[0]=0;
	while(1)
	{
		now+=c[++r];
		if(d[r]-d[l]>=k)break;
	}
	ans=min(ans,{now-c[l]-c[r],d[r]});
	for(;r<=cd;r++)
	{
		now+=c[r];
		while(1)
		{
			int _l=l+1;
			if(d[r]-d[_l]< k)break;
			now-=c[l++];
			ans=min(ans,{now-c[l]-c[r],d[r]});
		}
	}
	ans.Y%=m;
	printf("%d %d\n",ans.X,ans.Y);
	for(int i=1;i<=n;i++)
		if((a[i]> ans.Y-k&&a[i]< ans.Y)||(a[i]> ans.Y+m-k&&a[i]< ans.Y+m))
			printf("%d ",i);
	puts("");
}


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

ll n;
int main()
{
   // freopen("input.txt","r",stdin);
    cout<<"YES"<<endl;
    ll i;
    cin>>n;
    for(i=0; i<n; i++)
    {
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        a = abs(a)%2;
        b = abs(b)%2;
        if (!a && !b) cout<<3;
        else
            if (a && b) cout<<2;
        else
            if (a) cout<<4;
        else
            cout<<1;
        cout<<endl;
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
#define Fi firdq
#define Se second
#define pb(x) push_back(x)
#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))

#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321

int main() {
    cout << "YES" << endl;
    int n;
    cin >> n;
    while(n--) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        cout << ((12 + 2 * (x1 % 2) + (y1 % 2)) % 4) + 1 << endl;
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
#define Fi firdq
#define Se second
#define pb(x) push_back(x)
#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))

#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 987654321
#define IINF 987654321987654321

int main() {
    cout << "YES" << endl;
    int n;
    cin >> n;
    while(n--) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        cout << (12 + 2 * (a % 4) + (b % 4)) % 4 + 1 << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
inline void ri(int &x){
	x=0; static char c; bool t=0;
	while(c=getchar(),c<'0'||c>'9') if(c=='-') t=1; else t=0;
	do x=x*10+c-'0'; while(c=getchar(),c>='0'&&c<='9');
	if(t) x=-x;
}
int main(){
	int i,T,l,r,u,d; ri(T);
	cout<<"YES\n";
	while(T--){
		ri(l); ri(r); ri(u); ri(d);
		l=abs(min(l,r)); u=abs(min(u,d));
		if((l&1)&&(u&1)) puts("1");
		if((l&1)&&(~u&1)) puts("2");
		if((~l&1)&&(u&1)) puts("3");
		if((~l&1)&&(~u&1)) puts("4");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline void ri(int &x){
	x=0; static char c; bool t=0;
	while(c=getchar(),c<'0'||c>'9') if(c=='-') t=1; else t=0;
	do x=x*10+c-'0'; while(c=getchar(),c>='0'&&c<='9');
	if(t) x=-x;
}
int main(){
	int i,T,l,r,u,d; ri(T);
	cout<<"YES\n";
	while(T--){
		ri(l); ri(r); ri(u); ri(d);
		l=min(l,r); u=min(u,d);
		cout<<((l&1)+1)*((u&1)+1)<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline void ri(int &x){
	x=0; static char c; bool t=0;
	while(c=getchar(),c<'0'||c>'9') if(c=='-') t=1; else t=0;
	do x=x*10+c-'0'; while(c=getchar(),c>='0'&&c<='9');
	if(t) x=-x;
}
int main(){
	int i,T,l,r,u,d; ri(T);
	cout<<"YES\n";
	while(T--){
		ri(l); ri(u); ri(r); ri(d);
		l=abs(min(l,r)); u=abs(min(u,d));
		if((l&1)&&(u&1)) puts("1");
		if((l&1)&&(~u&1)) puts("2");
		if((~l&1)&&(u&1)) puts("3");
		if((~l&1)&&(~u&1)) puts("4");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline void ri(int &x){
	x=0; static char c; bool t=0;
	while(c=getchar(),c<'0'||c>'9') if(c=='-') t=1; else t=0;
	do x=x*10+c-'0'; while(c=getchar(),c>='0'&&c<='9');
	if(t) x=-x;
}
int main(){
	int i,T,l,r,u,d; ri(T);
	cout<<"YES\n";
	while(T--){
		ri(l); ri(r); ri(u); ri(d);
		l=abs(min(l,r)); u=abs(min(u,d));
		cout<<((l&1)+1)*((u&1)+1)<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
inline void ri(int &x){
	x=0; static char c; bool t=0;
	while(c=getchar(),c<'0'||c>'9') if(c=='-') t=1; else t=0;
	do x=x*10+c-'0'; while(c=getchar(),c>='0'&&c<='9');
	if(t) x=-x;
}
int main(){
	int i,T,l,r,u,d; ri(T);
	cout<<"YES\n";
	while(T--){
		ri(l); ri(r); ri(u); ri(d);
		l=abs(min(l,r)); u=abs(min(u,d));
		if((l&1)&&(u&1)) puts("1");
		if((l&1)&&(~u&1)) puts("2");
		if((~l&1)&&(r&1)) puts("3");
		if((~l&1)&&(~r&1)) puts("4");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main ()
{
	int n,x,y;
	scanf("%d",&n);
	puts("YES");
	while (n--)
	{
		scanf("%d%d%d%d",&x,&y,&x,&y);
		printf("%d\n",(x&1)*2+(y&1)+1);
	}
}


#include <bits/stdc++.h>

using namespace std;

int main ()
{
	int n;
	scanf("%d",&n);
	puts("YES");
	while (n--)
	{
		int x,y,x1,y1;
		scanf("%d%d%d%d",&x,&y,&x1,&y1);
		printf("%d\n",(x&1)*2+(y&1)+1);
	}
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 500005;

int n;
vi adj[N];
int rec[N][4];
hash_map<int, vi> stX, enX, stY, enY;
hash_map<int, hash_map<int, bool> > G;
short ans[N];
short col[N];
bool vis[N];
int deg[N];

struct cmpX {
	bool operator()(const int &i, const int &j) const {
		return rec[i][0] < rec[j][0];
	}
};

struct cmpY {
	bool operator()(const int &i, const int &j) const {
		return rec[i][1] < rec[j][1];
	}
};

void buildGraph() {
	for (int i = 0; i < n; i++) {
		auto &v1 = stX[rec[i][2]];
		int st = 0, en = SZ(v1) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v1[mid]][1] < rec[i][1])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v1); j++) {
			if (rec[v1[j]][1] >= rec[i][3]) {
				break;
			}
			if (!G[i][v1[j]] && !G[v1[j]][i]) {
				G[i][v1[j]] = G[v1[j]][i] = 1;
				adj[i].pb(v1[j]);
				adj[v1[j]].pb(i);
				deg[i]++;
				deg[v1[j]]++;
			}
		}
		auto &v2 = enX[rec[i][0]];
		st = 0, en = SZ(v2) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v2[mid]][1] < rec[i][1])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v2); j++) {
			if (rec[v2[j]][1] >= rec[i][3]) {
				break;
			}
			if (!G[i][v2[j]] && !G[v2[j]][i]) {
				G[i][v2[j]] = G[v2[j]][i] = 1;
				adj[i].pb(v2[j]);
				adj[v2[j]].pb(i);
				deg[i]++;
				deg[v2[j]]++;
			}
		}
		auto &v3 = stY[rec[i][3]];
		st = 0, en = SZ(v3) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v3[mid]][0] < rec[i][0])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v3); j++) {
			if (rec[v3[j]][0] >= rec[i][2]) {
				break;
			}
			if (!G[i][v3[j]] && !G[v3[j]][i]) {
				G[i][v3[j]] = G[v3[j]][i] = 1;
				adj[i].pb(v3[j]);
				adj[v3[j]].pb(i);
				deg[i]++;
				deg[v3[j]]++;
			}
		}
		auto &v4 = enY[rec[i][1]];
		st = 0, en = SZ(v4) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v4[mid]][0] < rec[i][0])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v4); j++) {
			if (rec[v4[j]][0] >= rec[i][2]) {
				break;
			}
			if (!G[i][v4[j]] && !G[v4[j]][i]) {
				G[i][v4[j]] = G[v4[j]][i] = 1;
				adj[i].pb(v4[j]);
				adj[v4[j]].pb(i);
				deg[i]++;
				deg[v4[j]]++;
			}
		}
	}
}

void init() {
	for (auto &it : stX) {
		sort(all(it.second), cmpY());
	}
	for (auto &it : enX) {
		sort(all(it.second), cmpY());
	}
	for (auto &it : stY) {
		sort(all(it.second), cmpX());
	}
	for (auto &it : enY) {
		sort(all(it.second), cmpX());
	}
	buildGraph();
}

pii arr[N];

void bfs(int st) {
	queue<int> Q;
	Q.push(st);
	vis[st] = 1;
	while (SZ(Q)) {
		int sz = SZ(Q);
		while (sz--) {
			int cur = Q.front();
			Q.pop();
			for (int i = 0; i < 4; i++) {
				if (!(col[cur] & (1 << i))) {
					ans[cur] = i + 1;
					break;
				}
			}
			for (auto to : adj[cur]) {
				col[to] |= 1 << (ans[cur] - 1);
			}
			for (auto to : adj[cur]) {
				if (!vis[to]) {
					vis[to] = 1;
					Q.push(to);
				}
			}
		}
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++)
			cin >> rec[i][j];
		stX[rec[i][0]].pb(i);
		enX[rec[i][2]].pb(i);
		stY[rec[i][1]].pb(i);
		enY[rec[i][3]].pb(i);
	}
	init();
//	for (int i = 0; i < n; i++) {
//		cout << i << ":";
//		for (auto to : adj[i]) {
//			cout << " " << to;
//		}
//		cout << "\n";
//	}
	for (int i = 0; i < n; i++) {
		arr[i] = mp(deg[i], i);
	}
	sort(arr, arr + n, greater<pii>());
	for (int i = 0; i < n; i++) {
		int cur = arr[i].second;
		if (!vis[cur]) {
			bfs(cur);
		}
	}
	cout << "YES\n";
	for (int i = 0; i < n; i++) {
		assert(ans[i]);
		cout << ans[i] << "\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 500005;

int n;
vi adj[N];
int rec[N][4];
hash_map<int, vi> stX, enX, stY, enY;
hash_map<int, hash_map<int, bool> > G;
short ans[N];
short col[N];
bool vis[N];

struct cmpX {
	bool operator()(const int &i, const int &j) const {
		return rec[i][0] < rec[j][0];
	}
};

struct cmpY {
	bool operator()(const int &i, const int &j) const {
		return rec[i][1] < rec[j][1];
	}
};

void buildGraph() {
	for (int i = 0; i < n; i++) {
		auto v1 = stX[rec[i][2]];
		int st = 0, en = SZ(v1) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v1[mid]][1] < rec[i][1])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v1); j++) {
			if (rec[v1[j]][1] >= rec[i][3]) {
				break;
			}
			if (!G[i][v1[j]] && !G[v1[j]][i]) {
				G[i][v1[j]] = G[v1[j]][i] = 1;
				adj[i].pb(v1[j]);
				adj[v1[j]].pb(i);
			}
		}
		auto v2 = enX[rec[i][0]];
		st = 0, en = SZ(v2) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v2[mid]][1] < rec[i][1])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v2); j++) {
			if (rec[v2[j]][1] >= rec[i][3]) {
				break;
			}
			if (!G[i][v2[j]] && !G[v2[j]][i]) {
				G[i][v2[j]] = G[v2[j]][i] = 1;
				adj[i].pb(v2[j]);
				adj[v2[j]].pb(i);
			}
		}
		auto v3 = stY[rec[i][3]];
		st = 0, en = SZ(v3) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v3[mid]][0] < rec[i][0])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v3); j++) {
			if (rec[v3[j]][0] >= rec[i][2]) {
				break;
			}
			if (!G[i][v3[j]] && !G[v3[j]][i]) {
				G[i][v3[j]] = G[v3[j]][i] = 1;
				adj[i].pb(v3[j]);
				adj[v3[j]].pb(i);
			}
		}
		auto v4 = enY[rec[i][1]];
		st = 0, en = SZ(v4) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v4[mid]][0] < rec[i][0])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v4); j++) {
			if (rec[v4[j]][0] >= rec[i][2]) {
				break;
			}
			if (!G[i][v4[j]] && !G[v4[j]][i]) {
				G[i][v4[j]] = G[v4[j]][i] = 1;
				adj[i].pb(v4[j]);
				adj[v4[j]].pb(i);
			}
		}
	}
}

void init() {
	for (auto it : stX) {
		sort(all(it.second), cmpY());
		stX[it.first] = it.second;
	}
	for (auto it : enX) {
		sort(all(it.second), cmpY());
		enX[it.first] = it.second;
	}
	for (auto it : stY) {
		sort(all(it.second), cmpX());
		stY[it.first] = it.second;
	}
	for (auto it : enY) {
		sort(all(it.second), cmpX());
		enY[it.first] = it.second;
	}
	buildGraph();
}

bool invalid;

void dfs(int cur) {
	int msk = 0;
	for (auto to : adj[cur]) {
		msk |= col[to];
		if (msk == 15) {
			invalid = 1;
			return;
		}
	}
	for (int i = 0; i < 4; i++) {
		if (!(msk & (1 << i))) {
			ans[cur] = i + 1;
			col[cur] = 1 << i;
			break;
		}
	}
	vis[cur] = 1;
	for (auto to : adj[cur]) {
		if (!vis[to]) {
			dfs(to);
		}
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++)
			cin >> rec[i][j];
		stX[rec[i][0]].pb(i);
		enX[rec[i][2]].pb(i);
		stY[rec[i][1]].pb(i);
		enY[rec[i][3]].pb(i);
	}
	init();
//	for (int i = 0; i < n; i++) {
//		cout << i << ":";
//		for (auto to : adj[i]) {
//			cout << " " << to;
//		}
//		cout << "\n";
//	}
	dfs(0);
	if (invalid) {
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	for (int i = 0; i < n; i++)
		cout << ans[i] << "\n";
	return 0;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 500005;

int n;
vi adj[N];
int rec[N][4];
hash_map<int, vi> stX, enX, stY, enY;
hash_map<int, hash_map<int, bool> > G;
short ans[N];
short col[N];
bool vis[N];

struct cmpX {
	bool operator()(const int &i, const int &j) const {
		return rec[i][0] < rec[j][0];
	}
};

struct cmpY {
	bool operator()(const int &i, const int &j) const {
		return rec[i][1] < rec[j][1];
	}
};

void buildGraph() {
	for (int i = 0; i < n; i++) {
		auto &v1 = stX[rec[i][2]];
		int st = 0, en = SZ(v1) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v1[mid]][1] < rec[i][1])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v1); j++) {
			if (rec[v1[j]][1] >= rec[i][3]) {
				break;
			}
			if (!G[i][v1[j]] && !G[v1[j]][i]) {
				G[i][v1[j]] = G[v1[j]][i] = 1;
				adj[i].pb(v1[j]);
				adj[v1[j]].pb(i);
			}
		}
		auto &v2 = enX[rec[i][0]];
		st = 0, en = SZ(v2) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v2[mid]][1] < rec[i][1])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v2); j++) {
			if (rec[v2[j]][1] >= rec[i][3]) {
				break;
			}
			if (!G[i][v2[j]] && !G[v2[j]][i]) {
				G[i][v2[j]] = G[v2[j]][i] = 1;
				adj[i].pb(v2[j]);
				adj[v2[j]].pb(i);
			}
		}
		auto &v3 = stY[rec[i][3]];
		st = 0, en = SZ(v3) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v3[mid]][0] < rec[i][0])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v3); j++) {
			if (rec[v3[j]][0] >= rec[i][2]) {
				break;
			}
			if (!G[i][v3[j]] && !G[v3[j]][i]) {
				G[i][v3[j]] = G[v3[j]][i] = 1;
				adj[i].pb(v3[j]);
				adj[v3[j]].pb(i);
			}
		}
		auto &v4 = enY[rec[i][1]];
		st = 0, en = SZ(v4) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v4[mid]][0] < rec[i][0])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v4); j++) {
			if (rec[v4[j]][0] >= rec[i][2]) {
				break;
			}
			if (!G[i][v4[j]] && !G[v4[j]][i]) {
				G[i][v4[j]] = G[v4[j]][i] = 1;
				adj[i].pb(v4[j]);
				adj[v4[j]].pb(i);
			}
		}
	}
}

void init() {
	for (auto &it : stX) {
		sort(all(it.second), cmpY());
	}
	for (auto &it : enX) {
		sort(all(it.second), cmpY());
	}
	for (auto &it : stY) {
		sort(all(it.second), cmpX());
	}
	for (auto &it : enY) {
		sort(all(it.second), cmpX());
	}
	buildGraph();
}

void dfs(int cur) {
	vis[cur] = 1;
	int msk = 0;
	for (auto to : adj[cur]) {
		msk |= col[to];
	}
	for (int i = 0; i < 4; i++) {
		if (!(msk & (1 << i))) {
			ans[cur] = i + 1;
			col[cur] = 1 << i;
			break;
		}
	}
	for (auto to : adj[cur]) {
		if (!vis[to]) {
			dfs(to);
		}
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++)
			cin >> rec[i][j];
		stX[rec[i][0]].pb(i);
		enX[rec[i][2]].pb(i);
		stY[rec[i][1]].pb(i);
		enY[rec[i][3]].pb(i);
	}
	init();
//	for (int i = 0; i < n; i++) {
//		cout << i << ":";
//		for (auto to : adj[i]) {
//			cout << " " << to;
//		}
//		cout << "\n";
//	}
	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			dfs(i);
		}
	}
	cout << "YES\n";
	for (int i = 0; i < n; i++) {
		assert(ans[i]);
		cout << ans[i] << "\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n, a, b, c, d;
	cout << "YES\n";
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c >> d;
		cout << (a % 2) + (b % 2) * 2 + 1 << "\n";
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 500005;

int n;
vi adj[N];
int rec[N][4];
hash_map<int, vi> stX, enX, stY, enY;
hash_map<int, hash_map<int, bool> > G;
short ans[N];
short col[N];
bool vis[N];

struct cmpX {
	bool operator()(const int &i, const int &j) const {
		return rec[i][0] < rec[j][0];
	}
};

struct cmpY {
	bool operator()(const int &i, const int &j) const {
		return rec[i][1] < rec[j][1];
	}
};

void buildGraph() {
	for (int i = 0; i < n; i++) {
		auto v1 = stX[rec[i][2]];
		int st = 0, en = SZ(v1) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v1[mid]][1] < rec[i][1])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v1); j++) {
			if (rec[v1[j]][1] >= rec[i][3]) {
				break;
			}
			if (!G[i][v1[j]] && !G[v1[j]][i]) {
				G[i][v1[j]] = G[v1[j]][i] = 1;
				adj[i].pb(v1[j]);
				adj[v1[j]].pb(i);
			}
		}
		auto v2 = enX[rec[i][0]];
		st = 0, en = SZ(v2) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v2[mid]][1] < rec[i][1])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v2); j++) {
			if (rec[v2[j]][1] >= rec[i][3]) {
				break;
			}
			if (!G[i][v2[j]] && !G[v2[j]][i]) {
				G[i][v2[j]] = G[v2[j]][i] = 1;
				adj[i].pb(v2[j]);
				adj[v2[j]].pb(i);
			}
		}
		auto v3 = stY[rec[i][3]];
		st = 0, en = SZ(v3) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v3[mid]][0] < rec[i][0])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v3); j++) {
			if (rec[v3[j]][0] >= rec[i][2]) {
				break;
			}
			if (!G[i][v3[j]] && !G[v3[j]][i]) {
				G[i][v3[j]] = G[v3[j]][i] = 1;
				adj[i].pb(v3[j]);
				adj[v3[j]].pb(i);
			}
		}
		auto v4 = enY[rec[i][1]];
		st = 0, en = SZ(v4) - 1;
		while (st < en) {
			int mid = st + (en - st) / 2;
			if (rec[v4[mid]][0] < rec[i][0])
				st = mid + 1;
			else
				en = mid;
		}
		for (int j = st; j < SZ(v4); j++) {
			if (rec[v4[j]][0] >= rec[i][2]) {
				break;
			}
			if (!G[i][v4[j]] && !G[v4[j]][i]) {
				G[i][v4[j]] = G[v4[j]][i] = 1;
				adj[i].pb(v4[j]);
				adj[v4[j]].pb(i);
			}
		}
	}
}

void init() {
	for (auto it : stX) {
		sort(all(it.second), cmpY());
		stX[it.first] = it.second;
	}
	for (auto it : enX) {
		sort(all(it.second), cmpY());
		enX[it.first] = it.second;
	}
	for (auto it : stY) {
		sort(all(it.second), cmpX());
		stY[it.first] = it.second;
	}
	for (auto it : enY) {
		sort(all(it.second), cmpX());
		enY[it.first] = it.second;
	}
	buildGraph();
}

void dfs(int cur) {
	int msk = 0;
	for (auto to : adj[cur]) {
		msk |= col[to];
	}
	for (int i = 0; i < 4; i++) {
		if (!(msk & (1 << i))) {
			ans[cur] = i + 1;
			col[cur] = 1 << i;
			break;
		}
	}
	vis[cur] = 1;
	for (auto to : adj[cur]) {
		if (!vis[to]) {
			dfs(to);
		}
	}
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 4; j++)
			cin >> rec[i][j];
		stX[rec[i][0]].pb(i);
		enX[rec[i][2]].pb(i);
		stY[rec[i][1]].pb(i);
		enY[rec[i][3]].pb(i);
	}
	init();
//	for (int i = 0; i < n; i++) {
//		cout << i << ":";
//		for (auto to : adj[i]) {
//			cout << " " << to;
//		}
//		cout << "\n";
//	}
	dfs(0);
	cout << "YES\n";
	for (int i = 0; i < n; i++)
		cout << ans[i] << "\n";
	return 0;
}


#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 1e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n, a, b, c, d;
	cout << "YES\n";
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c >> d;
                a += OO, b += OO, c += OO, d += OO;
		cout << (a % 2) + (b % 2) * 2 + 1 << "\n";
	}
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <queue>
#include <ctime>

using namespace std;

int main()
{
	//ifstream in("input.txt");
	//ofstream out("output.txt");
	int n;
	cin >> n;
	vector<int> ans(n);
	for (int i = 0; i < n; i++)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		ans[i] = 2 * (__min(a, c) % 2) + __min(b, d) % 2 + 1;
	}
	cout << "YES" << endl;
	for (int i = 0; i < n; i++)
		cout << ans[i] << endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <queue>
#include <ctime>

using namespace std;

const int INF = 1000000000;

int main()
{
	//ifstream in("input.txt");
	//ofstream out("output.txt");
	int n;
	cin >> n;
	vector<int> ans(n);
	for (int i = 0; i < n; i++)
	{
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		ans[i] = 2 * (__min(a + INF, c + INF) % 2) + __min(b + INF, d + INF) % 2 + 1;
	}
	cout << "YES" << endl;
	for (int i = 0; i < n; i++)
		cout << ans[i] << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec vector
#define pb push_back
#define s(x) scanf("%d",&x)
#define all(x)	x.begin(),x.end()
#define pii pair<int,int>
#define fi first
#define se second
#define SZ 100005
#define boost ios::sync_with_stdio(0);

int main()
{
	//freopen("input.txt","r",stdin);
	int n,x,y,z,u;
	int color[][2]={{1,2},{3,4}};
	cin>>n;
	cout<<"YES\n";
	for(int i=0; i<n; i++)
	{
		cin>>x>>y>>z>>u;
		x+=1e9*1LL,y+=1e9*1LL;
		cout<<color[x%2][y%2]<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vec vector
#define pb push_back
#define s(x) scanf("%d",&x)
#define all(x)	x.begin(),x.end()
#define pii pair<int,int>
#define fi first
#define se second
#define SZ 100005
#define boost ios::sync_with_stdio(0);

int main()
{
	//freopen("input.txt","r",stdin);
	int n,x,y;
	int color[][2]={{1,2},{3,4}};
	cin>>n;
	cout<<"YES\n";
	for(int i=0; i<n; i++)
	{
		cin>>x>>y;
		x+=1e9*1LL,y+=1e9*1LL;
		cout<<color[x%2][y%2]<<endl;
	}
}


// <!--encoding UTF-8 UTF-8编码--!>
/*****************************************************************************
*                      ----Stay Hungry Stay Foolish----                      *
*    @author    :   Shen                                                     *
*    @name      :   Codeforces Round #395 (Div. 2) D                         *
*****************************************************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
template<class T>inline bool updateMin(T& a, T b){ return a > b ? a = b, 1: 0; }
template<class T>inline bool updateMax(T& a, T b){ return a < b ? a = b, 1: 0; }
inline int    nextInt() { int x; scanf("%d", &x); return x; }
inline int64  nextI64() { int64  d; cin >> d; return d; }
inline char   nextChr() { scanf(" "); return getchar(); }
inline string nextStr() { string s; cin >> s; return s; }
inline double nextDbf() { double x; scanf("%lf", &x); return x; }
inline int64  nextlld() { int64 d; scanf("%lld", &d); return d; }
inline int64  next64d() { int64 d; scanf("%I64d",&d); return d; }

/*//Computational Geometry
#include <complex>
#define x real()
#define y imag()
typedef complex<double> point;
*/

int main()
{
	int n = nextInt();
	puts("YES");
	for (int i = 0; i < n; i++)
	{
		int x = nextInt();
		int y = nextInt();
		if (x & 1)
			puts(y & 1 ? "1" : "2");
		else
			puts(y & 1 ? "3" : "4");
	}
	return 0;
}


// <!--encoding UTF-8 UTF-8编码--!>
/*****************************************************************************
*                      ----Stay Hungry Stay Foolish----                      *
*    @author    :   Shen                                                     *
*    @name      :   Codeforces Round #395 (Div. 2) D                         *
*****************************************************************************/

#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
template<class T>inline bool updateMin(T& a, T b){ return a > b ? a = b, 1: 0; }
template<class T>inline bool updateMax(T& a, T b){ return a < b ? a = b, 1: 0; }
inline int    nextInt() { int x; scanf("%d", &x); return x; }
inline int64  nextI64() { int64  d; cin >> d; return d; }
inline char   nextChr() { scanf(" "); return getchar(); }
inline string nextStr() { string s; cin >> s; return s; }
inline double nextDbf() { double x; scanf("%lf", &x); return x; }
inline int64  nextlld() { int64 d; scanf("%lld", &d); return d; }
inline int64  next64d() { int64 d; scanf("%I64d",&d); return d; }

/*//Computational Geometry
#include <complex>
#define x real()
#define y imag()
typedef complex<double> point;
*/

int main()
{
	int n = nextInt();
	puts("YES");
	for (int i = 0; i < n; i++)
	{
		int x = nextInt();
		int y = nextInt();
		nextInt(); nextInt();
		if (x & 1)
			puts(y & 1 ? "1" : "2");
		else
			puts(y & 1 ? "3" : "4");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug0(x) printf("! %d\n", x);
#define debug1(x, a, b) for(int (ii)=(a);(ii)<(b);(ii++)) printf("%d: %d\n", ii, x[ii]);
#define nono(x, ite) for(__typeof((x).begin()) (ite)=(x).begin();(ite)!=(x).end();(ite++))

typedef long long ll;

const int N = 6e5 + 10;

int garx[2 * N], gary[2 * N], l1, l2, n;
int x1[N], y1[N], x2[N], y2[N], vis[N], ans[N];
vector<int> G[N];
vector<pair<int, int>> x[2 * N], y[2 * N];

void add(int u, int l, int r, int w, int type) {
  set<int> s;
  if (type == 0) {
    int lb = (int)(lower_bound(y[w].begin(), y[w].end(), mp(l, -100000000)) - y[w].begin());
    int rb = (int)(lower_bound(y[w].begin(), y[w].end(), mp(r, 100000000)) - y[w].begin());
    for (int i = lb; i < rb; i++) {
      if ((y[w][i].fi != l && y[w][i].fi != r) || (y[w][i].fi == l && y[w][i].se < 0) || (y[w][i].fi == r && y[w][i].se > 0))
        s.insert(abs(y[w][i].se));
    }
  } else {
    int lb = (int)(lower_bound(x[w].begin(), x[w].end(), mp(l, -100000000)) - x[w].begin());
    int rb = (int)(lower_bound(x[w].begin(), x[w].end(), mp(r, 100000000)) - x[w].begin());
    for (int i = lb; i < rb; i++) {
      if ((x[w][i].fi != l && x[w][i].fi != r)|| (x[w][i].fi == l && x[w][i].se < 0) || (x[w][i].fi == r && x[w][i].se > 0))
        s.insert(abs(x[w][i].se));
    }
  }
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    if(*it == u) continue;
    G[u - 1].pb(*it - 1);
    G[*it - 1].pb(u - 1);
  }
}

void dfs(int u) {
  vis[u] = 1;
  set<int> s;
  for (int i = 0; i < G[u].size(); i++) {
    s.insert(ans[G[u][i]]);
  }
  for (int i = 1; ; i++) {
    if (s.find(i) == s.end()) {
      ans[u] = i;
      break;
    }
  }
  for (int i = 0; i < G[u].size(); i++) {
    if (!vis[G[u][i]]) {
      dfs(G[u][i]);
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
    garx[l1++] = x1[i];
    gary[l2++] = y1[i];
    garx[l1++] = x2[i];
    gary[l2++] = y2[i];
  }
  sort(garx, garx + l1);
  sort(gary, gary + l2);
  l1 = unique(garx, garx + l1) - garx;
  l2 = unique(gary, gary + l2) - gary;
  for (int i = 0; i < n; i++) {
    x1[i] = lower_bound(garx, garx + l1, x1[i]) - garx;
    x2[i] = lower_bound(garx, garx + l1, x2[i]) - garx;
    y1[i] = lower_bound(gary, gary + l2, y1[i]) - gary;
    y2[i] = lower_bound(gary, gary + l2, y2[i]) - gary;
  }
  for (int i = 0; i < n; i++) {
    x[x1[i]].pb(mp(y1[i], -(i + 1)));
    x[x1[i]].pb(mp(y2[i], (i + 1)));
    x[x2[i]].pb(mp(y1[i], -(i + 1)));
    x[x2[i]].pb(mp(y2[i], (i + 1)));
    y[y1[i]].pb(mp(x1[i], -(i + 1)));
    y[y1[i]].pb(mp(x2[i], i + 1));
    y[y2[i]].pb(mp(x1[i], -(i + 1)));
    y[y2[i]].pb(mp(x2[i], i + 1));
  }
  for (int i = 0; i < l1; i++) {
    sort(x[i].begin(), x[i].end());
  }
  for (int i = 0; i < l2; i++) {
    sort(y[i].begin(), y[i].end());
  }
  for (int i = 0; i < n; i++) {
    add(i + 1, x1[i], x2[i], y1[i], 0);
    add(i + 1, x1[i], x2[i], y2[i], 0);
    add(i + 1, y1[i], y2[i], x1[i], 1);
    add(i + 1, y1[i], y2[i], x2[i], 1);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    dfs(i);
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug0(x) printf("! %d\n", x);
#define debug1(x, a, b) for(int (ii)=(a);(ii)<(b);(ii++)) printf("%d: %d\n", ii, x[ii]);
#define nono(x, ite) for(__typeof((x).begin()) (ite)=(x).begin();(ite)!=(x).end();(ite++))

typedef long long ll;

const int N = 6e5 + 10;

int garx[2 * N], gary[2 * N], l1, l2, n;
int x1[N], y1[N], x2[N], y2[N], vis[N], ans[N];
vector<int> G[N];
vector<pair<int, int>> x[2 * N], y[2 * N];

void add(int u, int l, int r, int w, int type) {
  set<int> s;
  if (type == 0) {
    int lb = (int)(lower_bound(y[w].begin(), y[w].end(), mp(l, -100000000)) - y[w].begin());
    int rb = (int)(lower_bound(y[w].begin(), y[w].end(), mp(r, 100000000)) - y[w].begin());
    for (int i = lb; i < rb; i++) {
      if ((y[w][i].fi != l && y[w][i].fi != r) || (y[w][i].fi == l && y[w][i].se < 0) || (y[w][i].fi == r && y[w][i].se > 0))
        s.insert(abs(y[w][i].se));
    }
  } else {
    int lb = (int)(lower_bound(x[w].begin(), x[w].end(), mp(l, -100000000)) - x[w].begin());
    int rb = (int)(lower_bound(x[w].begin(), x[w].end(), mp(r, 100000000)) - x[w].begin());
    for (int i = lb; i < rb; i++) {
      if ((x[w][i].fi != l && x[w][i].fi != r)|| (x[w][i].fi == l && x[w][i].se < 0) || (x[w][i].fi == r && x[w][i].se > 0))
        s.insert(abs(x[w][i].se));
    }
  }
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    if(*it == u) continue;
    G[u - 1].pb(*it - 1);
    G[*it - 1].pb(u - 1);
  }
}

void dfs(int u) {
  vis[u] = 1;
  set<int> s;
  for (int i = 0; i < G[u].size(); i++) {
    s.insert(ans[G[u][i]]);
  }
  for (int i = 1; i <= 4; i++) {
    if (s.find(i) == s.end()) {
      ans[u] = i;
      break;
    }
  }
  for (int i = 0; i < G[u].size(); i++) {
    if (!vis[G[u][i]]) {
      dfs(G[u][i]);
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
    garx[l1++] = x1[i];
    gary[l2++] = y1[i];
    garx[l1++] = x2[i];
    gary[l2++] = y2[i];
  }
  sort(garx, garx + l1);
  sort(gary, gary + l2);
  l1 = unique(garx, garx + l1) - garx;
  l2 = unique(gary, gary + l2) - gary;
  for (int i = 0; i < n; i++) {
    x1[i] = lower_bound(garx, garx + l1, x1[i]) - garx;
    x2[i] = lower_bound(garx, garx + l1, x2[i]) - garx;
    y1[i] = lower_bound(gary, gary + l2, y1[i]) - gary;
    y2[i] = lower_bound(gary, gary + l2, y2[i]) - gary;
  }
  for (int i = 0; i < n; i++) {
    x[x1[i]].pb(mp(y1[i], -(i + 1)));
    x[x1[i]].pb(mp(y2[i], (i + 1)));
    x[x2[i]].pb(mp(y1[i], -(i + 1)));
    x[x2[i]].pb(mp(y2[i], (i + 1)));
    y[y1[i]].pb(mp(x1[i], -(i + 1)));
    y[y1[i]].pb(mp(x2[i], i + 1));
    y[y2[i]].pb(mp(x1[i], -(i + 1)));
    y[y2[i]].pb(mp(x2[i], i + 1));
  }
  for (int i = 0; i < l1; i++) {
    sort(x[i].begin(), x[i].end());
  }
  for (int i = 0; i < l2; i++) {
    sort(y[i].begin(), y[i].end());
  }
  for (int i = 0; i < n; i++) {
    add(i + 1, x1[i], x2[i], y1[i], 0);
    add(i + 1, x1[i], x2[i], y2[i], 0);
    add(i + 1, y1[i], y2[i], x1[i], 1);
    add(i + 1, y1[i], y2[i], x2[i], 1);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    dfs(i);
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define debug0(x) printf("! %d\n", x);
#define debug1(x, a, b) for(int (ii)=(a);(ii)<(b);(ii++)) printf("%d: %d\n", ii, x[ii]);
#define nono(x, ite) for(__typeof((x).begin()) (ite)=(x).begin();(ite)!=(x).end();(ite++))

typedef long long ll;

const int N = 6e5 + 10;

int n, x, y, a;
int main() {
  scanf("%d", &n);
  printf("YES\n");
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &x, &y, &a, &a);
    printf("%d\n", 2 * (x & 1) + (y & 1) + 1);
  }
  return 0;
}
/*
int garx[2 * N], gary[2 * N], l1, l2, n;
int x1[N], y1[N], x2[N], y2[N], vis[N], ans[N];
vector<int> G[N];
vector<pair<int, int>> x[2 * N], y[2 * N];

void add(int u, int l, int r, int w, int type) {
  set<int> s;
  if (type == 0) {
    int lb = (int)(lower_bound(y[w].begin(), y[w].end(), mp(l, -100000000)) - y[w].begin());
    int rb = (int)(lower_bound(y[w].begin(), y[w].end(), mp(r, 100000000)) - y[w].begin());
    for (int i = lb; i < rb; i++) {
      if ((y[w][i].fi != l && y[w][i].fi != r) || (y[w][i].fi == l && y[w][i].se < 0) || (y[w][i].fi == r && y[w][i].se > 0))
        s.insert(abs(y[w][i].se));
    }
  } else {
    int lb = (int)(lower_bound(x[w].begin(), x[w].end(), mp(l, -100000000)) - x[w].begin());
    int rb = (int)(lower_bound(x[w].begin(), x[w].end(), mp(r, 100000000)) - x[w].begin());
    for (int i = lb; i < rb; i++) {
      if ((x[w][i].fi != l && x[w][i].fi != r)|| (x[w][i].fi == l && x[w][i].se < 0) || (x[w][i].fi == r && x[w][i].se > 0))
        s.insert(abs(x[w][i].se));
    }
  }
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    if(*it == u) continue;
    G[u - 1].pb(*it - 1);
    G[*it - 1].pb(u - 1);
  }
}

void dfs(int u) {
  vis[u] = 1;
  set<int> s;
  for (int i = 0; i < G[u].size(); i++) {
    s.insert(ans[G[u][i]]);
  }
  for (int i = 1; ; i++) {
    if (s.find(i) == s.end()) {
      ans[u] = i;
      break;
    }
  }
  for (int i = 0; i < G[u].size(); i++) {
    if (!vis[G[u][i]]) {
      dfs(G[u][i]);
    }
  }
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
    garx[l1++] = x1[i];
    gary[l2++] = y1[i];
    garx[l1++] = x2[i];
    gary[l2++] = y2[i];
  }
  sort(garx, garx + l1);
  sort(gary, gary + l2);
  l1 = unique(garx, garx + l1) - garx;
  l2 = unique(gary, gary + l2) - gary;
  for (int i = 0; i < n; i++) {
    x1[i] = lower_bound(garx, garx + l1, x1[i]) - garx;
    x2[i] = lower_bound(garx, garx + l1, x2[i]) - garx;
    y1[i] = lower_bound(gary, gary + l2, y1[i]) - gary;
    y2[i] = lower_bound(gary, gary + l2, y2[i]) - gary;
  }
  for (int i = 0; i < n; i++) {
    x[x1[i]].pb(mp(y1[i], -(i + 1)));
    x[x1[i]].pb(mp(y2[i], (i + 1)));
    x[x2[i]].pb(mp(y1[i], -(i + 1)));
    x[x2[i]].pb(mp(y2[i], (i + 1)));
    y[y1[i]].pb(mp(x1[i], -(i + 1)));
    y[y1[i]].pb(mp(x2[i], i + 1));
    y[y2[i]].pb(mp(x1[i], -(i + 1)));
    y[y2[i]].pb(mp(x2[i], i + 1));
  }
  for (int i = 0; i < l1; i++) {
    sort(x[i].begin(), x[i].end());
  }
  for (int i = 0; i < l2; i++) {
    sort(y[i].begin(), y[i].end());
  }
  for (int i = 0; i < n; i++) {
    add(i + 1, x1[i], x2[i], y1[i], 0);
    add(i + 1, x1[i], x2[i], y2[i], 0);
    add(i + 1, y1[i], y2[i], x1[i], 1);
    add(i + 1, y1[i], y2[i], x2[i], 1);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    dfs(i);
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
*/


#pragma warning(disable:4996)
#include<bits/stdc++.h>
//#include<iostream>
//#include<math.h>
//#include<vector>
//#include<algorithm>
//#include<utility>
//#include<stdio.h>
//#include<bitset>
using namespace std;
#define Maxn 500100
#define pp push_back
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll, ll> ii;
vector <vi> adjlist;
bitset <Maxn> bs;
vi primes;
void sieve(int upper_bound)
{
	primes.clear();
	bs.set();
	bs[0] = bs[1] = 0;
	for (ll i = 2; i <= upper_bound; i++)
	{
		if (bs[i]) {
			for (ll j = i*i; j <= upper_bound; j+=i) bs[j] = 0;
			primes.push_back(i);
		}
	}
}
ll gcd(int a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { if (a == 0 || b == 0) return max(a, b); return (a*(b / gcd(a, b))); }

ll ans1, ans2;
ll n;
ll rest;

void backtrack(ll sum, ll id, ll count)
{
	if (id*id*id > n) return;
	if (sum > n) return;
	if (count == ans1)
	{
		ans2 = max(ans2, sum); return;
	}
	if (sum + id*id*id <= (id + 1)*(id + 1)*(id + 1))
		backtrack(sum + id*id*id, id, count + 1);
	backtrack(sum , 1+id, count );
}

int main()
{
	int n;
	while (cin >> n)
	{
		rep(i, n)
		{
			ll x, y;
			scanf("%lld %lld %*lld %*lld", &x, &y);
			cout << (4 + 2 * x + y) % 4 + 1 << endl;

		}
	}
}


#pragma warning(disable:4996)
#include<bits/stdc++.h>
//#include<iostream>
//#include<math.h>
//#include<vector>
//#include<algorithm>
//#include<utility>
//#include<stdio.h>
//#include<bitset>
using namespace std;
#define Maxn 500100
#define pp push_back
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll, ll> ii;
vector <vi> adjlist;
bitset <Maxn> bs;
vi primes;
void sieve(int upper_bound)
{
	primes.clear();
	bs.set();
	bs[0] = bs[1] = 0;
	for (ll i = 2; i <= upper_bound; i++)
	{
		if (bs[i]) {
			for (ll j = i*i; j <= upper_bound; j+=i) bs[j] = 0;
			primes.push_back(i);
		}
	}
}
ll gcd(int a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { if (a == 0 || b == 0) return max(a, b); return (a*(b / gcd(a, b))); }

ll ans1, ans2;
ll n;
ll rest;

void backtrack(ll sum, ll id, ll count)
{
	if (id*id*id > n) return;
	if (sum > n) return;
	if (count == ans1)
	{
		ans2 = max(ans2, sum); return;
	}
	if (sum + id*id*id <= (id + 1)*(id + 1)*(id + 1))
		backtrack(sum + id*id*id, id, count + 1);
	backtrack(sum , 1+id, count );
}

int main()
{
	int n;
	while (cin >> n)
	{
		cout << "YES" << endl;
		rep(i, n)
		{
			ll x, y;
			scanf("%lld %lld %*lld %*lld", &x, &y);
			cout << (4 + 2 * x + y) % 4 + 1 << endl;

		}
	}
}


#pragma warning(disable:4996)
#include<bits/stdc++.h>
//#include<iostream>
//#include<math.h>
//#include<vector>
//#include<algorithm>
//#include<utility>
//#include<stdio.h>
//#include<bitset>
using namespace std;
#define Maxn 500100
#define pp push_back
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll, ll> ii;
vector <vi> adjlist;
bitset <Maxn> bs;
vi primes;
void sieve(int upper_bound)
{
	primes.clear();
	bs.set();
	bs[0] = bs[1] = 0;
	for (ll i = 2; i <= upper_bound; i++)
	{
		if (bs[i]) {
			for (ll j = i*i; j <= upper_bound; j+=i) bs[j] = 0;
			primes.push_back(i);
		}
	}
}
ll gcd(int a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { if (a == 0 || b == 0) return max(a, b); return (a*(b / gcd(a, b))); }

ll ans1, ans2;
ll n;
ll rest;

void backtrack(ll sum, ll id, ll count)
{
	if (id*id*id > n) return;
	if (sum > n) return;
	if (count == ans1)
	{
		ans2 = max(ans2, sum); return;
	}
	if (sum + id*id*id <= (id + 1)*(id + 1)*(id + 1))
		backtrack(sum + id*id*id, id, count + 1);
	backtrack(sum , 1+id, count );
}

int main()
{
	int n;
	/*freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout)*/;

	while (cin >> n)
	{
		cout << "YES" << endl;
		rep(i, n)
		{
			ll x, y;
			scanf("%lld %lld %*lld %*lld", &x, &y);
			cout << (4 + (2 * x)%4 + y%4) % 4 + 1 << endl;

		}
	}
}


#pragma warning(disable:4996)
#include<bits/stdc++.h>
//#include<iostream>
//#include<math.h>
//#include<vector>
//#include<algorithm>
//#include<utility>
//#include<stdio.h>
//#include<bitset>
using namespace std;
#define Maxn 500100
#define pp push_back
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll, ll> ii;
vector <vi> adjlist;
bitset <Maxn> bs;
vi primes;
void sieve(int upper_bound)
{
	primes.clear();
	bs.set();
	bs[0] = bs[1] = 0;
	for (ll i = 2; i <= upper_bound; i++)
	{
		if (bs[i]) {
			for (ll j = i*i; j <= upper_bound; j+=i) bs[j] = 0;
			primes.push_back(i);
		}
	}
}
ll gcd(int a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { if (a == 0 || b == 0) return max(a, b); return (a*(b / gcd(a, b))); }

ll ans1, ans2;
ll n;
ll rest;

void backtrack(ll sum, ll id, ll count)
{
	if (id*id*id > n) return;
	if (sum > n) return;
	if (count == ans1)
	{
		ans2 = max(ans2, sum); return;
	}
	if (sum + id*id*id <= (id + 1)*(id + 1)*(id + 1))
		backtrack(sum + id*id*id, id, count + 1);
	backtrack(sum , 1+id, count );
}

int main()
{
	int n;
	/*freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout)*/;

	while (cin >> n)
	{
		cout << "YES" << endl;
		rep(i, n)
		{
			ll x, y;
			scanf("%lld %lld %*lld %*lld", &x, &y);
			cout << (4 + (2 * x)%4 + y%2) % 4 + 1 << endl;

		}
	}
}


#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<fstream>
#include<string>
#include<cstring>
#include<cmath>
#include<tuple>
#include<functional>
#include<random>
#pragma warning(disable:4996)
using namespace std;
typedef uniform_int_distribution<int> random;
random_device rdd;
mt19937_64 el(rdd());
typedef long long ll;
const int INTMAX = 2147483647;
const long long LONGMAX = 9223372036854775807;
const double M_PI = 3.141592653589;

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a*b / gcd(a, b); }
ll ccw(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3)
{
	ll cmp = x1*y2 + x2*y3 + x3*y1 - y1*x2 - y2*x3 - y3*x1;
	if (cmp > 0) return 1;
	else if (cmp < 0) return -1;
	return 0;
}
int main()
{
	ios::sync_with_stdio(false);

	int n;

	cin >> n;
	cout << "YES\n";
	for (int i = 0; i < n; i++)
	{
		int a, b, c, d;

		cin >> a >> b >> c >> d;
		cout << 2 * (abs(a) % 2) + (abs(b) % 2) + 1 << "\n";
	}
}


#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<fstream>
#include<string>
#include<cstring>
#include<cmath>
#include<tuple>
#include<functional>
#include<random>
#pragma warning(disable:4996)
using namespace std;
typedef uniform_int_distribution<int> random;
random_device rdd;
mt19937_64 el(rdd());
typedef long long ll;
const int INTMAX = 2147483647;
const long long LONGMAX = 9223372036854775807;
const double M_PI = 3.141592653589;

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a*b / gcd(a, b); }

class Rect
{
public:
	ll no, sx, sy, ex, ey;
	ll hc;
	bool color[4];
	Rect() { memset(color, 0, sizeof(color)); }
	Rect(ll a, ll b, ll c, ll d) : sx(a), sy(b), ex(c), ey(d) { hc = 0; }
	bool operator <(const Rect &n) const
	{
		return n.sx == sx ? sy < n.sy : sx < n.sx;
	}
};
bool cmp(Rect a, Rect b)
{
	return a.no < b.no;
}
bool intersect(Rect a, Rect b)
{
	for (int i = 0; i < 2; i++)
	{
		if (a.ex == b.sx && a.sy <= b.sy && b.sy <= a.ey) return true;
		if (a.sy == b.ey && a.sx <= b.sx && b.sx <= a.ex) return true;
		if (a.sx == b.ex && a.sy <= b.ey && b.ey <= a.ey) return true;
		if (a.ey == b.sy && a.sx <= b.sx && b.sx <= a.ex) return true;
		swap(a, b);
	}
	return false;
}
int main()
{
	ios::sync_with_stdio(false);

	ll n;
	vector<Rect> v;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		ll a, b, c, d;

		cin >> a >> b >> c >> d;
		v.push_back({ a,b,c,d });
		v[i].no = i;
	}
	sort(v.begin(), v.end());

	ll colors = 1;

	for (int i = 0; i < n; i++)
	{
		if (v[i].hc) continue;
		v[i].hc = colors;
		ll bc = (colors + 1);
		if (bc == 5) bc = 1;
		if (colors == 5) colors = 1;
		for (int j = i + 1; j < n; j++)
		{
			if (v[i].ex < v[j].sx) break;
			if (!intersect(v[i], v[j])) v[j].hc = colors;
			else v[j].hc = bc;
		}
		colors++;
		if (colors == 5)colors = 1;
	}
	sort(v.begin(), v.end(), cmp);
	cout << "YES\n";
	for (int i = 0; i < n; i++) cout << v[i].hc << "\n";
}


#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<fstream>
#include<string>
#include<cstring>
#include<cmath>
#include<tuple>
#include<functional>
#include<random>
#pragma warning(disable:4996)
using namespace std;
typedef uniform_int_distribution<int> random;
random_device rdd;
mt19937_64 el(rdd());
typedef long long ll;
const int INTMAX = 2147483647;
const long long LONGMAX = 9223372036854775807;
const double M_PI = 3.141592653589;

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a*b / gcd(a, b); }

ll w[100001];
int main()
{
	ios::sync_with_stdio(false);

	int n;

	cin >> n;
	cout << "YES\n";
	auto rd = random(1, 4);
	for (int i = 0; i < n; i++)
	{
		auto here = rd(el);
		cout << here << "\n";
	}
}


//2017-02-02-23.08
//

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

struct node
{
    int x1, y1, x2, y2;
};

node d[500000+ 100];
int Record[500000+ 100];
bool check(int i, int j)
{

    if ((d[i].x1 == d[j].x2 && (d[i].y1 < d[j].y2 || d[i].y2 > d[j].y2)) ||
        (d[i].x2 == d[j].x1 && (d[i].y1 < d[j].y2 || d[i].y2 > d[j].y2))) return 1;
    else return 0;
}

void FourColorLabel(int num)
{
    Record[0]=1;
    int m=1, n=1;
    while (m<=num)
    {
        while(n<=4&& m<=num)
        {
            int k=0;
            for (k=0; k<m; k++)
            {
                if (check(m, k)==1 && Record[k]==n) break;
            }
            if (k<m) n++;
            else
            {
                Record[m]=n;
                m++;
                n=1;
            }
        }
        if (n>4)
        {
            m--;
            n=Record[m]+1;
        }
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d%d%d%d", &d[i].x1, &d[i].y1, &d[i].x2, &d[i].y2);
    }
    FourColorLabel(n);
    puts("YES");
    for (int i = 0; i < n; i++)
    {
        printf("%d\n", Record[i]);
    }
}


#include <stdio.h>

using namespace std;

int main()
{
    int n; scanf("%d", &n);
    int x1, y1, x2, y2;
    printf("YES\n");
    for (int i=0; i<n; i++)
    {
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        printf("%d\n",2 * (x1&1) + (y1&1) + 1);
    }
    return 0;
}


#include <iostream>

using namespace std;

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


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

typedef struct Rect {
    int x1, y1, x2, y2;
} Rect;

class TaskD {
private:
    inline bool overlap(const Rect &A, const Rect &B) {
        return (A.x1 <= B.x2 && A.x2 >= B.x1
                   && A.y1 < B.y2 && A.y2 > B.y1)
                || (A.x1 < B.x2 && A.x2 > B.x1
                    && A.y1 <= B.y2 && A.y2 >= B.y1);
    }

    bool dfs(int u, const vector<vector<int>> &g, vector<int> &color) {
        int col = 1;
        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (color[v] == col) {
                ++col;
            }
        }
        if (col == 5) {
            return false;
        }
        color[u] = col;

        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (color[v] == 0) {
                if (!dfs(v, g, color)) {
                    return false;
                }
            }
        }
        return true;
    }
public:
    void solve(istream& in, ostream& out) {
        int n;
        in >> n;

        //map<int,vector<int>> top, bot, left, right;
        vector<Rect> rects(n);
        for (int i = 0; i < n; ++i) {
            in >> rects[i].x1 >> rects[i].y1 >> rects[i].x2 >> rects[i].y2;
            //top[rects[i].y2].push_back(i);
            //bot[rects[i].y1].push_back(i);
            //left[rects[i].x1].push_back(i);
            //right[rects[i].x2].push_back(i);
        }

        /*vector<vector<int>> g(n);
        for (int i = 0; i < n; ++i) {
            if (top.find(rects[i].y1) != top.end()) {
                const vector<int> &v = top[rects[i].y1];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (bot.find(rects[i].y2) != bot.end()) {
                const vector<int> &v = bot[rects[i].y2];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (left.find(rects[i].x2) != left.end()) {
                const vector<int> &v = left[rects[i].x2];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (right.find(rects[i].x1) != right.end()) {
                const vector<int> &v = right[rects[i].x1];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
        }*/

        /*vector<int> color(n, 0);
        for (int i = 0; i < n; ++i) {
            if (color[i] == 0) {
                if (!dfs(i, g, color)) {
                    out << "NO\n";
                    return;
                }
            }
        }

        out << "YES\n";
        for (int i = 0; i < n; ++i) {
            out << color[i] << "\n";
        }*/

        out << "YES\n";
        for (int i = 0; i < n; ++i) {
            if ((rects[i].x1 % 2 + 2) % 2 == 0 && (rects[i].y1 % 2 + 2) % 2 == 0) {
                out << "1\n";
            } else if ((rects[i].x1 % 2 + 2) % 2 == 1 && (rects[i].y1 % 2 + 2) % 2 == 0) {
                out << "2\n";
            } else if ((rects[i].x1 % 2 + 2) % 2 == 1 && (rects[i].y1 % 2 + 2) % 2 == 1) {
                out << "3\n";
            } else if ((rects[i].x1 % 2 + 2) % 2 == 0 && (rects[i].y1 % 2 + 2) % 2 == 1) {
                out << "4\n";
            }
        }
    }
};

int main() {
	std::ios::sync_with_stdio(false);

	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

typedef struct Rect {
    int x1, y1, x2, y2;
} Rect;

class TaskD {
private:
    inline bool overlap(const Rect &A, const Rect &B) {
        return (A.x1 <= B.x2 && A.x2 >= B.x1
                   && A.y1 < B.y2 && A.y2 > B.y1)
                || (A.x1 < B.x2 && A.x2 > B.x1
                    && A.y1 <= B.y2 && A.y2 >= B.y1);
    }

    bool dfs(int u, const vector<vector<int>> &g, vector<int> &color) {
        int col = 1;
        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (color[v] == col) {
                ++col;
            }
        }
        if (col == 5) {
            return false;
        }
        color[u] = col;

        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (color[v] == 0) {
                if (!dfs(v, g, color)) {
                    return false;
                }
            }
        }
        return true;
    }
public:
    void solve(istream& in, ostream& out) {
        int n;
        in >> n;

        map<int,vector<int>> top, bot, left, right;
        vector<Rect> rects(n);
        for (int i = 0; i < n; ++i) {
            in >> rects[i].x1 >> rects[i].y1 >> rects[i].x2 >> rects[i].y2;
            top[rects[i].y2].push_back(i);
            bot[rects[i].y1].push_back(i);
            left[rects[i].x1].push_back(i);
            right[rects[i].x2].push_back(i);
        }

        vector<vector<int>> g(n);
        for (int i = 0; i < n; ++i) {
            if (top.find(rects[i].y1) != top.end()) {
                const vector<int> &v = top[rects[i].y1];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (bot.find(rects[i].y2) != bot.end()) {
                const vector<int> &v = bot[rects[i].y2];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (left.find(rects[i].x2) != left.end()) {
                const vector<int> &v = left[rects[i].x2];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (right.find(rects[i].x1) != right.end()) {
                const vector<int> &v = right[rects[i].x1];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
        }

        vector<int> color(n, 0);
        for (int i = 0; i < n; ++i) {
            if (color[i] == 0) {
                if (!dfs(i, g, color)) {
                    //out << "NO\n";
                    //return;
                }
            }
        }

        out << "YES\n";
        for (int i = 0; i < n; ++i) {
            out << color[i] << "\n";
        }
    }
};

int main() {
	std::ios::sync_with_stdio(false);

	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

typedef struct Rect {
    int x1, y1, x2, y2;
} Rect;

class TaskD {
private:
    inline bool overlap(const Rect &A, const Rect &B) {
        return (A.x1 <= B.x2 && A.x2 >= B.x1
                   && A.y1 < B.y2 && A.y2 > B.y1)
                || (A.x1 < B.x2 && A.x2 > B.x1
                    && A.y1 <= B.y2 && A.y2 >= B.y1);
    }

    bool dfs(int u, const vector<vector<int>> &g, vector<int> &color) {
        int col = 1;
        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (color[v] == col) {
                ++col;
            }
        }
        if (col == 5) {
            --col;
        }
        color[u] = col;

        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (color[v] == 0) {
                if (!dfs(v, g, color)) {
                    return false;
                }
            }
        }
        return true;
    }
public:
    void solve(istream& in, ostream& out) {
        int n;
        in >> n;

        map<int,vector<int>> top, bot, left, right;
        vector<Rect> rects(n);
        for (int i = 0; i < n; ++i) {
            in >> rects[i].x1 >> rects[i].y1 >> rects[i].x2 >> rects[i].y2;
            top[rects[i].y2].push_back(i);
            bot[rects[i].y1].push_back(i);
            left[rects[i].x1].push_back(i);
            right[rects[i].x2].push_back(i);
        }

        vector<vector<int>> g(n);
        for (int i = 0; i < n; ++i) {
            if (top.find(rects[i].y1) != top.end()) {
                const vector<int> &v = top[rects[i].y1];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (bot.find(rects[i].y2) != bot.end()) {
                const vector<int> &v = bot[rects[i].y2];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (left.find(rects[i].x2) != left.end()) {
                const vector<int> &v = left[rects[i].x2];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (right.find(rects[i].x1) != right.end()) {
                const vector<int> &v = right[rects[i].x1];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
        }

        vector<int> color(n, 0);
        for (int i = 0; i < n; ++i) {
            if (color[i] == 0) {
                if (!dfs(i, g, color)) {
                    //out << "NO\n";
                    //return;
                }
            }
        }

        out << "YES\n";
        for (int i = 0; i < n; ++i) {
            out << color[i] << "\n";
        }
    }
};

int main() {
	std::ios::sync_with_stdio(false);

	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <cassert>

using namespace std;

typedef struct Rect {
    int x1, y1, x2, y2;
} Rect;

class TaskD {
private:
    inline bool overlap(const Rect &A, const Rect &B) {
        return (A.x1 <= B.x2 && A.x2 >= B.x1
                   && A.y1 < B.y2 && A.y2 > B.y1)
                || (A.x1 < B.x2 && A.x2 > B.x1
                    && A.y1 <= B.y2 && A.y2 >= B.y1);
    }

    bool dfs(int u, const vector<vector<int>> &g, vector<int> &color) {
        int col = 1;
        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (color[v] == col) {
                ++col;
            }
        }
        if (col == 5) {
            return false;
        }
        color[u] = col;

        for (int i = 0; i < (int)g[u].size(); ++i) {
            int v = g[u][i];
            if (color[v] == 0) {
                if (!dfs(v, g, color)) {
                    return false;
                }
            }
        }
        return true;
    }
public:
    void solve(istream& in, ostream& out) {
        int n;
        in >> n;

        map<int,vector<int>> top, bot, left, right;
        vector<Rect> rects(n);
        for (int i = 0; i < n; ++i) {
            in >> rects[i].x1 >> rects[i].y1 >> rects[i].x2 >> rects[i].y2;
            top[rects[i].y2].push_back(i);
            bot[rects[i].y1].push_back(i);
            left[rects[i].x1].push_back(i);
            right[rects[i].x2].push_back(i);
        }

        vector<vector<int>> g(n);
        for (int i = 0; i < n; ++i) {
            if (top.find(rects[i].y1) != top.end()) {
                const vector<int> &v = top[rects[i].y1];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (bot.find(rects[i].y2) != bot.end()) {
                const vector<int> &v = bot[rects[i].y2];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (left.find(rects[i].x2) != left.end()) {
                const vector<int> &v = left[rects[i].x2];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
            if (right.find(rects[i].x1) != right.end()) {
                const vector<int> &v = right[rects[i].x1];
                for (int j = 0; j < (int)v.size(); ++j) {
                    if (i != v[j] && overlap(rects[i], rects[v[j]])) {
                        g[i].push_back(v[j]);
                        g[v[j]].push_back(i);
                        //cout << "add edge " << i << " " << v[j] << "\n";
                    }
                }
            }
        }

        vector<int> color(n, 0);
        for (int i = 0; i < n; ++i) {
            if (color[i] == 0) {
                if (!dfs(i, g, color)) {
                    out << "NO\n";
                    return;
                }
            }
        }

        out << "YES\n";
        for (int i = 0; i < n; ++i) {
            out << color[i] << "\n";
        }
    }
};

int main() {
	std::ios::sync_with_stdio(false);

	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int aa[2000600];
int haha[2000600];
int main()
{
    int n;
    scanf("%d",&n);
    int x,y;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        scanf("%d%d",&x,&y);
        if(x%2==0)
        {
            if(y%2==0)
                cout<<1<<endl;
            else
                cout<<2<<endl;
        }
        else
        {
            if(y%2==0)
                cout<<3<<endl;
            else
                cout<<4<<endl;
        }
    }
}