#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
const int MX = 1e5+1, INF = 1e9;
int n, m, k, q;
int R[4*MX], C[4*MX];

struct pos {
	int x, y;
}rk[MX];

bool rk_cmpY(pos a, pos b) {
	return a.y < b.y;
}

struct ask {
	int x, y, X, Y;
	int flag, ans;
}Q[MX];

bool cmpY(ask a, ask b) {
	return a.Y < b.Y;
}

void build(int node, int b, int e) {
	R[node] = 0;
	if (b == e) {
		return;
	}
	build(2*node, b, (b+e)/2);
	build(2*node+1, (b+e)/2+1, e);
}

int query(int node, int b, int e, int i, int j) {
	if (i > e || j < b) return -1;
	if (i <= b && e <= j) return R[node];
	int x, y;
	x = query(2*node, b, (b+e)/2, i, j);
	y = query(2*node+1, (b+e)/2+1, e, i, j);
	if (x == -1) return y;
	if (y == -1) return x;
	return min(x, y);
}

void update(int node, int b, int e, int i, int val) {
	if (i < b || i > e) return;
	if (b == e) {
		R[node] = val;
		return;
	}
	update(2*node, b, (b+e)/2, i, val);
	update(2*node+1, (b+e)/2+1, e, i, val);
	R[node] = min(R[2*node], R[2*node+1]);
}

bool ret(ask a, ask b) {
	return a.flag < b.flag;
}

int main() {
	scanf("%d%d%d%d", &n, &m, &k, &q);
	for (int i = 0; i < k; i++) {
		scanf("%d%d", &rk[i].x, &rk[i].y);
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d%d", &Q[i].x, &Q[i].y, &Q[i].X, &Q[i].Y);
		Q[i].flag = i;
		Q[i].ans = 0;
	}
	for (int j = 0; j < 2; j++) {
		sort(rk, rk+k, rk_cmpY);
		sort(Q, Q+q, cmpY);
		build(1, 1, n);
		int f = 0, g = 0;
		for (int i = 1; i <= m; i++) {
			while (f < k && rk[f].y == i) {
				update(1, 1, n, rk[f].x, i);
				f++;
			}
			while (g < q && Q[g].Y == i) {
				int tmp = query(1, 1, n, Q[g].x, Q[g].X);
				if (query(1, 1, n, Q[g].x, Q[g].X) >= Q[g].y) {
					Q[g].ans = 1;
				}
				g++;
			}
		}
		if (j == 1) break;
		swap(n, m);
		for (int i = 0; i < k; i++) {
			swap(rk[i].x, rk[i].y);
		}
		for (int i = 0; i < q; i++) {
			swap(Q[i].x, Q[i].y);
			swap(Q[i].X, Q[i].Y);
		}
	}
	sort(Q, Q+q, ret);
	for (int i = 0; i < q; i++) {
		if (Q[i].ans == 1) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
const int MX = 1e5+1, INF = 1e9;
int n, m, k, q;
int R[4*MX], C[4*MX];

struct pos {
	int x, y;
}rk[MX];

bool rk_cmpY(pos a, pos b) {
	return a.y < b.y;
}

struct ask {
	int x, y, X, Y;
	int flag, ans;
}Q[MX];

bool cmpY(ask a, ask b) {
	return a.Y < b.Y;
}

void build(int node, int b, int e) {
	R[node] = 0;
	if (b == e) {
		return;
	}
	build(2*node, b, (b+e)/2);
	build(2*node+1, (b+e)/2+1, e);
}

int query(int node, int b, int e, int i, int j) {
	if (i > e || j < b) return -1;
	if (i <= b && e <= j) return R[node];
	int x, y;
	x = query(2*node, b, (b+e)/2, i, j);
	y = query(2*node+1, (b+e)/2+1, e, i, j);
	if (x == -1) return y;
	if (y == -1) return x;
	return min(x, y);
}

void update(int node, int b, int e, int i, int val) {
	if (i < b || i > e) return;
	if (b == e) {
		R[node] = val;
		return;
	}
	update(2*node, b, (b+e)/2, i, val);
	update(2*node+1, (b+e)/2+1, e, i, val);
	R[node] = min(R[2*node], R[2*node+1]);
}

bool ret(ask a, ask b) {
	return a.flag < b.flag;
}

int main() {
	scanf("%d%d%d%d", &n, &m, &k, &q);
	for (int i = 0; i < k; i++) {
		scanf("%d%d", &rk[i].x, &rk[i].y);
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d%d", &Q[i].x, &Q[i].y, &Q[i].X, &Q[i].Y);
		Q[i].flag = i;
		Q[i].ans = 0;
	}
	for (int j = 0; j < 2; j++) {
		sort(rk, rk+k, rk_cmpY);
		sort(Q, Q+q, cmpY);
		build(1, 1, m);
		int f = 0, g = 0;
		for (int i = 1; i <= m; i++) {
			while (f < k && rk[f].y == i) {
				update(1, 1, m, rk[f].x, i);
				f++;
			}
			while (g < q && Q[g].Y == i) {
				int tmp = query(1, 1, m, Q[g].x, Q[g].X);
				if (query(1, 1, m, Q[g].x, Q[g].X) >= Q[g].y) {
					Q[g].ans = 1;
				}
				g++;
			}
		}
		if (j == 1) break;
		swap(n, m);
		for (int i = 0; i < k; i++) {
			swap(rk[i].x, rk[i].y);
		}
		for (int i = 0; i < q; i++) {
			swap(Q[i].x, Q[i].y);
			swap(Q[i].X, Q[i].Y);
		}
	}
	sort(Q, Q+q, ret);
	for (int i = 0; i < q; i++) {
		if (Q[i].ans == 1) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
const int MX = 1e5+1;
int n, m, k, q;
int R[4*MX];

struct pos {
	int x, y;
}rk[2*MX];

bool rk_cmpY(pos a, pos b) {
	return a.y < b.y;
}

struct ask {
	int x, y, X, Y;
	int flag, ans;
}Q[2*MX];

bool cmpY(ask a, ask b) {
	return a.Y < b.Y;
}

void build(int node, int b, int e) {
	R[node] = 0;
	if (b == e) {
		return;
	}
	build(2*node, b, (b+e)/2);
	build(2*node+1, (b+e)/2+1, e);
}

int query(int node, int b, int e, int i, int j) {
	if (i > e || j < b) return -1;
	if (i <= b && e <= j) return R[node];
	int x, y;
	x = query(2*node, b, (b+e)/2, i, j);
	y = query(2*node+1, (b+e)/2+1, e, i, j);
	if (x == -1) return y;
	if (y == -1) return x;
	return min(x, y);
}

void update(int node, int b, int e, int i, int val) {
	if (i < b || i > e) return;
	if (b == e) {
		R[node] = val;
		return;
	}
	update(2*node, b, (b+e)/2, i, val);
	update(2*node+1, (b+e)/2+1, e, i, val);
	R[node] = min(R[2*node], R[2*node+1]);
}

bool ret(ask a, ask b) {
	return a.flag < b.flag;
}

int main() {
	scanf("%d%d%d%d", &n, &m, &k, &q);
	for (int i = 0; i < k; i++) {
		scanf("%d%d", &rk[i].x, &rk[i].y);
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d%d", &Q[i].x, &Q[i].y, &Q[i].X, &Q[i].Y);
		Q[i].flag = i;
		Q[i].ans = 0;
	}
	for (int j = 0; j < 2; j++) {
		sort(rk, rk+k, rk_cmpY);
		sort(Q, Q+q, cmpY);
		build(1, 1, n);
		int f = 0, g = 0;
		for (int i = 1; i <= m; i++) {
			while (f < k && rk[f].y == i) {
				update(1, 1, n, rk[f].x, i);
				f++;
			}
			while (g < q && Q[g].Y == i) {
				int tmp = query(1, 1, n, Q[g].x, Q[g].X);
				if (query(1, 1, n, Q[g].x, Q[g].X) >= Q[g].y) {
					Q[g].ans = 1;
				}
				g++;
			}
		}
		if (j == 1) break;
		swap(n, m);
		for (int i = 0; i < k; i++) {
			swap(rk[i].x, rk[i].y);
		}
		for (int i = 0; i < q; i++) {
			swap(Q[i].x, Q[i].y);
			swap(Q[i].X, Q[i].Y);
		}
	}
	sort(Q, Q+q, ret);
	for (int i = 0; i < q; i++) {
		if (Q[i].ans == 1) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define F first
#define S second

#define endl '\n'

#define mp make_pair
#define pb push_back

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

#define type(x) __typeof((x).begin())
#define foreach(i, x) for(type(x) i = (x).begin(); i != (x).end(); i++)

#define sol (root + root)
#define sag (root + root + 1)
#define orta ((bas + son) >> 1)

#define bit __builtin_popcount

#ifndef D
	#define dbg(x) 0
	#define dbgs(x) 0
#else
	#define dbg(x) cerr << (#x) << " --> " << (x) << endl
	#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#endif

typedef long long ll;
typedef pair < int, int > pii;

const int inf = 1e9 + 5;
const ll linf = 1e18 + 5;

const int N = 2e5 + 5;

const int M = 1e5 + 5;

int n, m, k, q, kd[M << 2];

bool ans[N];

pii a[N];

pair < pii, pii > qu[N];

vector < int > rookx[N], rooky[N];

vector < pair < pii, pii > > queries[N];

int init(int root, int bas, int son) {

	if(bas == son)
	{
		if(rooky[bas].empty())
			kd[root] = inf;
		else
			kd[root] = rooky[bas].front();

		return kd[root];
	}

	return kd[root] = max(init(sol, bas, orta), init(sag, orta + 1, son));

}

int update(int root, int bas, int son, int x, int k) {

	if(son < x or x < bas)
		return kd[root];

	if(x <= bas and son <= x)
		return kd[root] = k;

	return kd[root] = max(update(sol, bas, orta, x, k), update(sag, orta + 1, son, x, k));

}

int query(int root, int bas, int son, int x, int y) {

	if(son < x or y < bas)
		return 0;

	if(x <= bas and son <= y)
		return kd[root];

	return max(query(sol, bas, orta, x, y), query(sag, orta + 1, son, x, y));

}

void solve() {

	init(1, 1, m);

	int cur;

	FOR(i, 1, n)
	{
		foreach(it, queries[i])
			if(query(1, 1, m, it -> S.F, it -> S.S) <= it -> F.F)
				ans[it -> F.S] = 1;

		foreach(it, rookx[i])
		{
			cur = upper_bound(rooky[*it].begin(), rooky[*it].end(), i) - rooky[*it].begin();

			if(cur == rooky[*it].size())
				cur = inf;
			else
				cur = rooky[*it][cur];

			update(1, 1, m, *it, cur);
		}
	}

}

int main() {

	ios :: sync_with_stdio(0);

	cin >> n >> m >> k >> q;

	FOR(i, 1, k)
	{
		cin >> a[i].F >> a[i].S;

		rookx[a[i].F].pb(a[i].S);
		rooky[a[i].S].pb(a[i].F);
	}

	FOR(i, 1, n)
		sort(rookx[i].begin(), rookx[i].end());

	FOR(i, 1, m)
		sort(rooky[i].begin(), rooky[i].end());

	FOR(i, 1, q)
	{
		cin >> qu[i].F.F >> qu[i].F.S >> qu[i].S.F >> qu[i].S.S;

		queries[qu[i].F.F].pb(mp(mp(qu[i].S.F, i), mp(qu[i].F.S, qu[i].S.S)));
	}

	solve();

	FOR(i, 1, n)
		queries[i].clear();

	FOR(i, 1, q)
		queries[qu[i].F.S].pb(mp(mp(qu[i].S.S, i), mp(qu[i].F.F, qu[i].S.F)));

	FOR(i, 1, n)
		rookx[i].clear();

	FOR(i, 1, m)
		rooky[i].clear();

	FOR(i, 1, k)
	{
		rookx[a[i].S].pb(a[i].F);
		rooky[a[i].F].pb(a[i].S);
	}

	swap(n, m);

	FOR(i, 1, n)
		sort(rookx[i].begin(), rookx[i].end());

	FOR(i, 1, m)
		sort(rooky[i].begin(), rooky[i].end());

	solve();

	FOR(i, 1, q)
		if(ans[i])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;

	return 0;

}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int n,m,k,q,i,j,x,y,g,z,tree[400005],ans[200005];
pair <int, int> a[100005];

struct que{
    int x, x1, y, y1, id;
}b[100005];

bool cmp(que u, que v){
    return u.y1 < v.y1;
}

void update(int l, int r, int ind){

    if(l == r){
        tree[ind] = y;
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
    update(l, mid, ind * 2);
    else
    update(mid + 1, r, ind * 2 + 1);
    tree[ind] = min(tree[ind * 2], tree[ind * 2 + 1]);

}

void query(int l, int r, int ind){

    if(x <= l && r <= y){
        g = min(g, tree[ind]);
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
    query(l, mid, ind * 2);
    if(y > mid)
    query(mid + 1, r, ind * 2 + 1);

}
int main(){

    scanf("%d%d%d%d", &n, &m, &k, &q);
    for(i = 0; i < k; i++)
    scanf("%d%d", &a[i].second, &a[i].first);
    for(i = 0; i < q; i++){
        scanf("%d%d%d%d", &b[i].x, &b[i].y, &b[i].x1, &b[i].y1);
        b[i].id = i;
    }
    sort(a, a + k);
    sort(b, b + q, cmp);
    memset(tree, 0, sizeof(tree));
    int p = 0;
    for(i = 0; i < q; i++){
        while(a[p].first <= b[i].y1 && p < k){
            x = a[p].second;
            y = a[p].first;
            update(1, n, 1);
            p++;
        }
        g = 1000000005;
        x = b[i].x;
        y = b[i].x1;
        query(1, n, 1);
        bool flag = 0;
        if(g >= b[i].y)
        flag = 1;
        else
        flag = 0;
        ans[b[i].id] = flag;
    }
    memset(tree, 0, sizeof(tree));
    for(i = 0; i < k; i++)
    swap(a[i].first, a[i].second);
    for(i = 0; i < q; i++){
        swap(b[i].x, b[i].y);
        swap(b[i].x1, b[i].y1);
    }
    sort(a, a + k);
    sort(b, b + q, cmp);
    p = 0;
    for(i = 0; i < q; i++){
        while(a[p].first <= b[i].y1 && p < k){
            x = a[p].second;
            y = a[p].first;
            update(1, m, 1);
            p++;
        }
        g = 1000000005;
        x = b[i].x;
        y = b[i].x1;
        query(1, m, 1);
        bool flag = 0;
        if(g >= b[i].y)
        flag = 1;
        else
        flag = 0;
        ans[b[i].id] |= flag;
    }
    for(i = 0; i < q; i++){
        if(ans[i])
        printf("YES\n");
        else
        printf("NO\n");
    }
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int n,m,k,q,i,j,x,y,g,z,tree[400005],ans[200005];
pair <int, int> a[200005];

struct que{
    int x, x1, y, y1, id;
}b[200005];

bool cmp(que u, que v){
    return u.y1 < v.y1;
}

void update(int l, int r, int ind){

    if(l == r){
        tree[ind] = y;
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
    update(l, mid, ind * 2);
    else
    update(mid + 1, r, ind * 2 + 1);
    tree[ind] = min(tree[ind * 2], tree[ind * 2 + 1]);

}

void query(int l, int r, int ind){

    if(x <= l && r <= y){
        g = min(g, tree[ind]);
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
    query(l, mid, ind * 2);
    if(y > mid)
    query(mid + 1, r, ind * 2 + 1);

}
int main(){

    scanf("%d%d%d%d", &n, &m, &k, &q);
    for(i = 0; i < k; i++)
    scanf("%d%d", &a[i].second, &a[i].first);
    for(i = 0; i < q; i++){
        scanf("%d%d%d%d", &b[i].x, &b[i].y, &b[i].x1, &b[i].y1);
        b[i].id = i;
    }
    sort(a, a + k);
    sort(b, b + q, cmp);
    memset(tree, 0, sizeof(tree));
    int p = 0;
    for(i = 0; i < q; i++){
        while(a[p].first <= b[i].y1 && p < k){
            x = a[p].second;
            y = a[p].first;
            update(1, n, 1);
            p++;
        }
        g = 1000000005;
        x = b[i].x;
        y = b[i].x1;
        query(1, n, 1);
        bool flag = 0;
        if(g >= b[i].y)
        flag = 1;
        else
        flag = 0;
        ans[b[i].id] = flag;
    }
    memset(tree, 0, sizeof(tree));
    for(i = 0; i < k; i++)
    swap(a[i].first, a[i].second);
    for(i = 0; i < q; i++){
        swap(b[i].x, b[i].y);
        swap(b[i].x1, b[i].y1);
    }
    sort(a, a + k);
    sort(b, b + q, cmp);
    p = 0;
    for(i = 0; i < q; i++){
        while(a[p].first <= b[i].y1 && p < k){
            x = a[p].second;
            y = a[p].first;
            update(1, m, 1);
            p++;
        }
        g = 1000000005;
        x = b[i].x;
        y = b[i].x1;
        query(1, m, 1);
        bool flag = 0;
        if(g >= b[i].y)
        flag = 1;
        else
        flag = 0;
        ans[b[i].id] |= flag;
    }
    for(i = 0; i < q; i++){
        if(ans[i])
        printf("YES\n");
        else
        printf("NO\n");
    }
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int n,m,k,q,i,j,x,y,g,z,tree[400005],ans[200005];
pair <int, int> a[100005];

struct que{
    int x, x1, y, y1, id;
}b[100005];

bool cmp(que u, que v){
    return u.y1 < v.y1;
}

void update(int l, int r, int ind){

    if(l == r){
        tree[ind] = y;
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
    update(l, mid, ind * 2);
    else
    update(mid + 1, r, ind * 2 + 1);
    tree[ind] = min(tree[ind * 2], tree[ind * 2 + 1]);

}

void query(int l, int r, int ind){

    if(x <= l && r <= y){
        g = min(g, tree[ind]);
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
    query(l, mid, ind * 2);
    if(y > mid)
    query(mid + 1, r, ind * 2 + 1);

}
int main(){

    scanf("%d%d%d%d", &n, &m, &k, &q);
    for(i = 0; i < k; i++)
    scanf("%d%d", &a[i].second, &a[i].first);
    for(i = 0; i < q; i++){
        scanf("%d%d%d%d", &b[i].x, &b[i].y, &b[i].x1, &b[i].y1);
        b[i].id = i;
    }
    sort(a, a + k);
    sort(b, b + q, cmp);
    memset(tree, 0, sizeof(tree));
    int p = 0;
    for(i = 0; i < q; i++){
        while(a[p].first <= b[i].y1 && p < k){
            x = a[p].second;
            y = a[p].first;
            update(1, n, 1);
            p++;
        }
        g = 1000000005;
        x = b[i].x;
        y = b[i].x1;
        query(1, n, 1);
        bool flag = 0;
        if(g >= b[i].y)
        flag = 1;
        else
        flag = 0;
        ans[b[i].id] = flag;
    }
    memset(tree, 0, sizeof(tree));
    for(i = 0; i < k; i++)
    swap(a[i].first, a[i].second);
    for(i = 0; i < q; i++){
        swap(b[i].x, b[i].y);
        swap(b[i].x1, b[i].y1);
    }
    sort(a, a + k);
    sort(b, b + q, cmp);
    p = 0;
    for(i = 0; i < q; i++){
        while(a[p].first <= b[i].y1 && p < k){
            x = a[p].second;
            y = a[p].first;
            update(1, n, 1);
            p++;
        }
        g = 1000000005;
        x = b[i].x;
        y = b[i].x1;
        query(1, n, 1);
        bool flag = 0;
        if(g >= b[i].y)
        flag = 1;
        else
        flag = 0;
        ans[b[i].id] |= flag;
    }
    for(i = 0; i < q; i++){
        if(ans[i])
        printf("YES\n");
        else
        printf("NO\n");
    }
}


#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int n,m,k,q,i,j,x,y,g,z,tree[400005],ans[200005];
pair <int, int> a[100005];

struct que{
    int x, x1, y, y1, id;
}b[100005];

bool cmp(que u, que v){
    return u.y1 < v.y1;
}

void update(int l, int r, int ind){

    if(l == r){
        tree[ind] = y;
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
    update(l, mid, ind * 2);
    else
    update(mid + 1, r, ind * 2 + 1);
    tree[ind] = min(tree[ind * 2], tree[ind * 2 + 1]);

}

void query(int l, int r, int ind){

    if(x <= l && r <= y){
        g = min(g, tree[ind]);
        return;
    }
    int mid = (l + r) / 2;
    if(x <= mid)
    query(l, mid, ind * 2);
    if(y > mid)
    query(mid + 1, r, ind * 2 + 1);

}
int main(){

    scanf("%d%d%d%d", &n, &m, &k, &q);
    for(i = 0; i < k; i++)
    scanf("%d%d", &a[i].second, &a[i].first);
    for(i = 0; i < q; i++){
        scanf("%d%d%d%d", &b[i].x, &b[i].y, &b[i].x1, &b[i].y1);
        b[i].id = i;
    }
    sort(a, a + k);
    sort(b, b + q, cmp);
    memset(tree, 0, sizeof(tree));
    int p = 0;
    for(i = 0; i < q; i++){
        while(a[p].first <= b[i].y1 && p < k){
            x = a[p].second;
            y = a[p].first;
            update(1, n, 1);
            p++;
        }
        g = 1000000005;
        x = b[i].x;
        y = b[i].x1;
        query(1, n, 1);
        bool flag = 0;
        if(g >= b[i].y)
        flag = 1;
        else
        flag = 0;
        ans[b[i].id] = flag;
    }
    memset(tree, 0, sizeof(tree));
    for(i = 0; i < k; i++)
    swap(a[i].first, a[i].second);
    for(i = 0; i < q; i++){
        swap(b[i].x, b[i].y);
        swap(b[i].x1, b[i].y1);
    }
    sort(a, a + k);
    sort(b, b + q, cmp);
    p = 0;
    for(i = 0; i < q; i++){
        while(a[p].first <= b[i].y1 && p < k){
            x = a[p].second;
            y = a[p].first;
            update(1, n, 1);
            p++;
        }
        g = 1000000005;
        x = b[i].x;
        y = b[i].x1;
        query(1, m, 1);
        bool flag = 0;
        if(g >= b[i].y)
        flag = 1;
        else
        flag = 0;
        ans[b[i].id] |= flag;
    }
    for(i = 0; i < q; i++){
        if(ans[i])
        printf("YES\n");
        else
        printf("NO\n");
    }
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
#define Pi 3.14159265358979

typedef long long Int;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;

const int INF = 1000000000;
const int MAX = 400007;
const int MAX2 = 7000;
const int BASE = 1000000000;

struct RMQ
{
    int n;
    int T[MAX * 4];
    RMQ(){};
    RMQ(int len)
    {
        n = len;
        FOR (i,0,n*4)
            T[i] = -INF;
    }
    void Set(int j, int d, int i, int l, int r)
    {
        if (l == r)
        {
            T[i] = d;
        }
        else
        {
            int m = (l+r)/2;
            if (j <= m)
                Set(j, d, i*2, l, m);
            else
                Set(j, d, i*2+1, m+1, r);
            T[i] = max(T[i*2], T[i*2+1]);
        }
    }
    int GetMax(int l, int r, int i, int tl, int tr)
    {
        if (l == tl && r == tr)
            return T[i];
        int m = (tl+tr)/2;
        if (r <= m)
            return GetMax(l, r, i*2, tl, m);
        if (l > m)
            return GetMax(l, r, i*2+1, m+1, tr);
        int a = GetMax(l, m, i*2, tl, m);
        int b = GetMax(m+1, r, i*2+1, m+1, tr);
        return max(a, b);
    }
};

int n, m, k, q;
int cnt;
PII A[MAX];
pair<PII, PII> Q[MAX];
PII P[MAX];
bool U[MAX];
int Next[MAX];
int Prev[MAX];
int I[MAX];
int C[MAX];
int Res[MAX][2];
vector <PII> In[MAX];
vector <PII> Out[MAX];
RMQ T;

void Solve(int N, int M, int w)
{
    FILL(U, 0);
    FOR (i,0,k)
    {
        P[i] = A[i];
        U[A[i].second] = 1;
    }
    cnt = k;
    FOR (i,0,M)
        if (U[i] == 0)
            P[cnt ++] = MP(INF, i);
    sort(P, P+cnt);
    FOR (i,0,M)
        I[i] = -INF;
    FOR (i,0,cnt)
    {
        int y = P[i].second;
        Prev[i] = I[y];
        I[y] = i;
    }
    FOR (i,0,M)
        I[i] = INF;
    RFOR (i,cnt,0)
    {
        int y = P[i].second;
        Next[i] = I[y];
        I[y] = i;
    }
    FOR (i,0,cnt)
    {
        In[i].clear();
        Out[i].clear();
    }
    FILL(C, 0);
    FOR (i,0,q)
    {
        PII p = Q[i].first;
        int a = lower_bound(P, P+cnt, MP(p.first, -INF)) - P;
        int b = upper_bound(P, P+cnt, MP(p.second, INF)) - P - 1;
        if (a > b)
            C[i] = 2;
        else
        {
            In[a].PB(MP(b, i));
            Out[b].PB(MP(a, i));
        }
    }

    T = RMQ(M);
    int pos = 0;
    FOR (i,0,cnt)
    {
        FOR (j,0,SZ(In[i]))
        {
            int id = In[i][j].second;
            int r = In[i][j].first;
            int val = T.GetMax(Q[id].second.first, Q[id].second.second, 1, 0, T.n-1);
            if (val > r)
                ++ C[id];
        }
        //while (pos < i && P[pos].first < P[i].first)
        T.Set(P[i].second, Next[i], 1, 0, T.n-1);
    }
    T = RMQ(M);
    RFOR (i,cnt,0)
    {
        FOR (j,0,SZ(Out[i]))
        {
            int id = Out[i][j].second;
            int l = Out[i][j].first;
            int val = -T.GetMax(Q[id].second.first, Q[id].second.second, 1, 0, T.n-1);
            if (val < l)
                ++ C[id];
        }
        T.Set(P[i].second, -Prev[i], 1, 0, T.n-1);
    }
    //FOR (i,0,cnt)
      //  cout << P[i].first << ' ' << P[i].second << endl;
    //FOR (i,0,q)
      //  cout << C[i] << endl;
    FOR (i,0,q)
        if (C[i] > 0)
            Res[i][w] = 0;
        else
            Res[i][w] = 1;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
    #endif

    scanf("%d %d %d %d", &n, &m, &k, &q);
    //n = 10;
    //m = 100;
    //k = 500;
    //q = 100000;
    FOR (i,0,k)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        //x = rand() % n + 1;
        //y = rand() % m + 1;
        -- x;
        -- y;
        A[i] = MP(x, y);
    }
    FOR (i,0,q)
    {
        int x, y, xx, yy;
        scanf("%d %d %d %d", &x, &y, &xx, &yy);
        //yy = rand() % m + 1;
        //y = rand() % yy + 1;
        //xx = rand() % n + 1;
        //x = rand() % xx + 1;
        -- x;
        -- y;
        -- xx;
        -- yy;
        Q[i] = MP(MP(x, xx), MP(y, yy));
    }

    Solve(n, m, 0);

    //FOR (i,0,q)
      //  cout << Res[i][0] << ' ' << Res[i][1] << endl;

    FOR (i,0,k)
        swap(A[i].first, A[i].second);
    FOR (i,0,q)
        swap(Q[i].first, Q[i].second);

    Solve(m, n, 1);

    //FOR (i,0,q)
      //  cout << Res[i][0] << ' ' << Res[i][1] << endl;

    FOR (i,0,q)
    {

        if (Res[i][0] || Res[i][1])
            printf("YES\n");
        else
            printf("NO\n");

        /*
        set<int> S1;
        set<int> S2;
        FOR (j,0,k)
            if (A[j].first >= Q[i].first.first && A[j].first <= Q[i].first.second)
                if (A[j].second >= Q[i].second.first && A[j].second <= Q[i].second.second)
                {
                        S2.insert(A[j].second);
                        S1.insert(A[j].first);
                }
        bool res0 = 0, res1 = 0;
        if (S1.size() == Q[i].first.second - Q[i].first.first + 1)
            res0 = 1;
        if (S2.size() == Q[i].second.second - Q[i].second.first + 1)
            res1 = 1;
        if (res0 != Res[i][0])
            cout << "EROOR" << endl;
        if (res1 != Res[i][1])
            cout << "EROOR" << endl;
        //cout << res0 << ' ' << res1 << ' ' << SZ(S1) << ' ' << SZ(S2) << ' ' << Res[i][0] << ' ' << Res[i][1] << endl;
        //cout << Q[i].first.first << ' ' << Q[i].first.second << ' ' << Q[i].second.first << ' ' << Q[i].second.second << endl;
        */
    }

    return 0;
}


#include <bits/stdc++.h>
#define MA(a,b) ((a)>(b)?(a):(b))
#define MI(a,b) ((a)<(b)?(a):(b))
#define AB(a) (-(a)<(a)?(a):-(a))
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ep 0.00000001
#define pi 3.1415926535897932384626433832795
#define na(x) ((x)<P?(x):(x)-P)

using namespace std;
const int N=220000;
const long long P=1000000007;
int n,m,k,q;
int ans[N];
pair<int,int> a[N];
struct ele{
    int x,y,xx,yy,I;
} b[N];

int tr[N*2];
void cl(int l,int r,int x){
    if (l+1<r){
        cl(l,(l+r)/2,x*2);
        cl((l+r)/2,r,x*2+1);
    }
    tr[x]=0;
}
void add(int l,int r,int x,int ind,int mn){
    if (l+1==r){
        tr[x]=mn;
        return;
    }
    if ((l+r)/2<=ind) add((l+r)/2,r,x*2+1,ind,mn);
    else             add(l,(l+r)/2,x*2,ind,mn);
    tr[x]=MI(tr[x*2],tr[x*2+1]);

}
int cal(int l,int r,int x,int ll,int rr){
    if (l>rr || r-1<ll) return N;
    if (ll<=l && r-1<=rr) return tr[x];
    return min(cal(l,(l+r)/2,x*2,ll,rr),cal((l+r)/2,r,x*2+1,ll,rr));
}
bool boo(ele A,ele B){
    return A.xx<B.xx;
}

void sol(){
    sort(a+1,a+k+1);
    cl(1,m+1,1);
    sort(b+1,b+q+1,boo);
    int I=1;
    for (int i=1;i<=q;i++){
        while (I<=k  && a[I].X<=b[i].xx){
            add(1,m+1,1,a[I].Y,a[I].X);
            I++;
        }
        ans[b[i].I]+=(cal(1,m+1,1,b[i].y,b[i].yy)>=b[i].x);
    }
}
int main() {
    freopen("text","r",stdin);
    scanf("%d%d%d%d",&n,&m,&k,&q);
    for (int i=1;i<=k;i++) scanf("%d%d",&a[i].X,&a[i].Y);
    for (int i=1;i<=q;i++)
    scanf("%d%d%d%d",&b[i].x,&b[i].y,&b[i].xx,&b[i].yy),b[i].I=i;
    m=MA(n,m);
    sol();
    for (int i=1;i<=q;i++) swap(b[i].x,b[i].y),swap(b[i].xx,b[i].yy);
    for (int i=1;i<=k;i++) swap(a[i].X,a[i].Y);

    sol();

    for (int i=1;i<=q;i++) printf(ans[i]>0?"YES\n":"NO\n");
    return 0;
}


#include <bits/stdc++.h>
#define MA(a,b) ((a)>(b)?(a):(b))
#define MI(a,b) ((a)<(b)?(a):(b))
#define AB(a) (-(a)<(a)?(a):-(a))
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ep 0.00000001
#define pi 3.1415926535897932384626433832795
#define na(x) ((x)<P?(x):(x)-P)

using namespace std;
const int N=220000;
const long long P=1000000007;
int n,m,k,q;
int ans[N];
pair<int,int> a[N];
struct ele{
    int x,y,xx,yy,I;
} b[N];

int tr[N*2];
void cl(int l,int r,int x){
    if (l+1<r){
        cl(l,(l+r)/2,x*2);
        cl((l+r)/2,r,x*2+1);
    }
    tr[x]=0;
}
void add(int l,int r,int x,int ind,int mn){
    if (l+1==r){
        tr[x]=mn;
        return;
    }
    if ((l+r)/2<=ind) add((l+r)/2,r,x*2+1,ind,mn);
    else             add(l,(l+r)/2,x*2,ind,mn);
    tr[x]=MI(tr[x*2],tr[x*2+1]);

}
int cal(int l,int r,int x,int ll,int rr){
    if (l>rr || r-1<ll) return N;
    if (ll<=l && r-1<=rr) return tr[x];
    return min(cal(l,(l+r)/2,x*2,ll,rr),cal((l+r)/2,r,x*2+1,ll,rr));
}
bool boo(ele A,ele B){
    return A.xx<B.xx;
}

void sol(){
    sort(a+1,a+k+1);
    cl(1,m+1,1);
    sort(b+1,b+q+1,boo);
    int I=1;
    for (int i=1;i<=q;i++){
        while (I<=k  && a[I].X<=b[i].xx){
            add(1,m+1,1,a[I].Y,a[I].X);
            I++;
        }
        ans[b[i].I]+=(cal(1,m+1,1,b[i].y,b[i].yy)>=b[i].x);
    }
}
int main() {
    //freopen("text","r",stdin);
    scanf("%d%d%d%d",&n,&m,&k,&q);
    for (int i=1;i<=k;i++) scanf("%d%d",&a[i].X,&a[i].Y);
    for (int i=1;i<=q;i++)
    scanf("%d%d%d%d",&b[i].x,&b[i].y,&b[i].xx,&b[i].yy),b[i].I=i;
    m=MA(n,m);
    sol();
    for (int i=1;i<=q;i++) swap(b[i].x,b[i].y),swap(b[i].xx,b[i].yy);
    for (int i=1;i<=k;i++) swap(a[i].X,a[i].Y);

    sol();

    for (int i=1;i<=q;i++) printf(ans[i]>0?"YES\n":"NO\n");
    return 0;
}


//Solution by Zhusupov Nurlan
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <ctime>

using namespace std;

typedef long long LL;
typedef map<string , int> MSI;
typedef vector<int> VI;
typedef pair<int, int> PII;

#define pb(x) push_back(x)
#define sqr(x) ((x) * (x))
#define F first
#define S second
#define SZ(t) ((int) t.size())
#define len(t) ((int) t.length())
#define base LL(1e9 + 7)
#define fname ""
#define sz 1000 * 1000
#define EPS (1e-8)
#define INF ((int)1e9 + 9)
#define write(xx) printf("%d" , xx);
#define readln(xx) getline(cin , xx)
#define read(xx) scanf("%d" , &xx)
#define mp make_pair

const double PI  = acos(-1.0);

struct point
{
    int x, y;
} a[sz], b[sz], r[sz];

int n, m, k, q, t[sz];
VI g[sz], qq[sz];
string ans[sz];

void upd(int v, int l, int r, int p, int x)
{
    if (l == r)
        t[v] = x;
    else
    {
        int m = (l + r) >> 1;
        if (p <= m)
            upd(v + v, l, m, p, x);
        else
            upd(v + v + 1, m + 1, r, p, x);
        t[v] = min(t[v + v], t[v + v + 1]);
    }
}

int get(int v, int tl, int tr, int l, int r)
{
    if (l > r)
        return INF;
    if (tl == l && tr == r)
        return t[v];
    int m = (tl + tr) >> 1;
    return min(get(v + v, tl, m, l, min(r, m)), get(v + v + 1, m + 1, tr, max(l, m + 1), r));
}

void build(int v, int l, int r)
{
    t[v] = 0;
    if (l != r)
    {
        int m = (l + r) >> 1;
        build(v + v, l, m);
        build(v + v + 1, m + 1, r);
    }
}

int main()
{
    //    freopen("in", "r", stdin);
    //i    freopen("out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m >> k >> q;

    for (int i = 1; i <= k; i++)
        cin >> r[i].x >> r[i].y;

    for (int i = 1; i <= q; i++)
    {
        cin >> a[i].x >> a[i].y >> b[i].x >> b[i].y;
        ans[i] = "NO";
    }

    for (int i = 1; i <= k; i++)
        g[r[i].x].pb(r[i].y);

    for (int i = 1; i <= q; i++)
        qq[b[i].x].pb(i);
    int p = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < g[i].size(); j++)
            upd(1, 1, m, g[i][j], i);

        for (int j = 0; j < qq[i].size(); j++)
        {
            p = qq[i][j];
            if (get(1, 1, m, a[p].y, b[p].y) >= a[p].x)
                ans[p] = "YES";
        }
        g[i].clear();
        qq[i].clear();
    }
    for (int i = 1; i <= k; i++)
        g[r[i].y].pb(r[i].x);
    for (int i = 1; i <= q; i++)
        qq[b[i].y].pb(i);
    build(1, 1, n);
    for (int i = 1; i <= m; i++)
    {
        for (int j = 0; j < g[i].size(); j++)
            upd(1, 1, n, g[i][j], i);
        for (int j = 0; j < qq[i].size(); j++)
        {
            p = qq[i][j];
            if (get(1, 1, n, a[p].x, b[p].x) >= a[p].y)
                ans[p] = "YES";
        }
    }

    for (int i = 1; i <= q; i++)
        cout << ans[i] << "\n";

}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<PII,PII> PIIII;
typedef pair<PIIII,int> PV;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define MOD 1000000007
#define INF 2000000000

int n, m, k, q;

const int MAXN = (1 << 17) + 10; const int NN = (1 << 17) - 1;
int rt[MAXN], ct[MAXN];

vector<PII> rowrook, colrook;

vector<PV> rowquery, colquery;

const int MAXQ = 200010;
int res[MAXQ];

int main() {
    scanf("%d%d%d%d", &n, &m, &k, &q);

    int x, y;

    FORN(i, k) {
        scanf("%d%d", &x, &y);

        rowrook.PB(MP(x, y));
        colrook.PB(MP(y, x));
    }

    sort(rowrook.begin(), rowrook.end());
    sort(colrook.begin(), colrook.end());

    int x1, y1, x2, y2;

    FORN(i, q) {
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

        colquery.PB(MP(MP(MP(y2, y1), MP(x1, x2)), i+1));
        rowquery.PB(MP(MP(MP(x2, x1), MP(y1, y2)), i+1));
    }

    sort(rowquery.begin(), rowquery.end());
    sort(colquery.begin(), colquery.end());

    memset(res, 0, sizeof res);

    memset(rt, -1, sizeof rt);

    // step through the columns
    int rookidx = 0; int queryidx = 0;

    FOR1(j, m) {
        // process rooks
        while (rookidx < k && colrook[rookidx].FF == j) {
            int r = colrook[rookidx].SS;

            rt[NN + r] = j;
            for (int node = (NN+r)/2; node; node /= 2) rt[node] = min(rt[2*node], rt[2*node+1]);

            rookidx++;
        }

        // process queries
        while (queryidx < q && colquery[queryidx].FF.FF.FF == j) {
            int ln = NN + colquery[queryidx].FF.SS.FF;
            int rn = NN + colquery[queryidx].FF.SS.SS;

            int mm = INF;

            while (ln <= rn) {
                if ( (ln & 1)) mm = min(mm, rt[ln]);
                if (!(rn & 1)) mm = min(mm, rt[rn]);

                ln = (ln + 1) / 2;
                rn = (rn - 1) / 2;
            }

            if (mm >= colquery[queryidx].FF.FF.SS) res[colquery[queryidx].SS] = 1;

            queryidx++;
        }
    }

    memset(ct, -1, sizeof ct);

    // step through the columns
    rookidx = 0; queryidx = 0;

    FOR1(i, n) {
        // process rooks
        while (rookidx < k && rowrook[rookidx].FF == i) {
            int c = rowrook[rookidx].SS;

            ct[NN + c] = i;
            for (int node = (NN+c)/2; node; node /= 2) ct[node] = min(ct[2*node], ct[2*node+1]);

            rookidx++;
        }

        // process queries
        while (queryidx < q && rowquery[queryidx].FF.FF.FF == i) {
            int ln = NN + rowquery[queryidx].FF.SS.FF;
            int rn = NN + rowquery[queryidx].FF.SS.SS;

            int mm = INF;

            while (ln <= rn) {
                if ( (ln & 1)) mm = min(mm, ct[ln]);
                if (!(rn & 1)) mm = min(mm, ct[rn]);

                ln = (ln + 1) / 2;
                rn = (rn - 1) / 2;
            }

            if (mm >= rowquery[queryidx].FF.FF.SS) res[rowquery[queryidx].SS] = 1;

            queryidx++;
        }
    }

    FOR1(i, q) {
        if (res[i]) printf("YES\n");
        else printf("NO\n");
    }

    return 0;
}


#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<PII,PII> PIIII;
typedef pair<PIIII,int> PV;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define MOD 1000000007
#define INF 2000000000

int n, m, k, q;

const int MAXN = (1 << 17) + 10; const int NN = (1 << 17) - 1;
int rt[2*MAXN], ct[2*MAXN];

vector<PII> rowrook, colrook;

vector<PV> rowquery, colquery;

const int MAXQ = 200010;
int res[MAXQ];

int main() {
    scanf("%d%d%d%d", &n, &m, &k, &q);

    int x, y;

    FORN(i, k) {
        scanf("%d%d", &x, &y);

        rowrook.PB(MP(x, y));
        colrook.PB(MP(y, x));
    }

    sort(rowrook.begin(), rowrook.end());
    sort(colrook.begin(), colrook.end());

    int x1, y1, x2, y2;

    FORN(i, q) {
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

        colquery.PB(MP(MP(MP(y2, y1), MP(x1, x2)), i+1));
        rowquery.PB(MP(MP(MP(x2, x1), MP(y1, y2)), i+1));
    }

    sort(rowquery.begin(), rowquery.end());
    sort(colquery.begin(), colquery.end());

    memset(res, 0, sizeof res);

    memset(rt, -1, sizeof rt);

    // step through the columns
    int rookidx = 0; int queryidx = 0;

    FOR1(j, m) {
        // process rooks
        while (rookidx < k && colrook[rookidx].FF == j) {
            int r = colrook[rookidx].SS;

            rt[NN + r] = j;
            for (int node = (NN+r)/2; node; node /= 2) rt[node] = min(rt[2*node], rt[2*node+1]);

            rookidx++;
        }

        // process queries
        while (queryidx < q && colquery[queryidx].FF.FF.FF == j) {
            int ln = NN + colquery[queryidx].FF.SS.FF;
            int rn = NN + colquery[queryidx].FF.SS.SS;

            int mm = INF;

            while (ln <= rn) {
                if ( (ln & 1)) mm = min(mm, rt[ln]);
                if (!(rn & 1)) mm = min(mm, rt[rn]);

                ln = (ln + 1) / 2;
                rn = (rn - 1) / 2;
            }

            if (mm >= colquery[queryidx].FF.FF.SS) res[colquery[queryidx].SS] = 1;

            queryidx++;
        }

        if (j == m && (rookidx != k || queryidx != q)) cout << rookidx << " " << queryidx << endl;
    }

    memset(ct, -1, sizeof ct);

    // step through the rows
    rookidx = 0; queryidx = 0;

    FOR1(i, n) {
        // process rooks
        while (rookidx < k && rowrook[rookidx].FF == i) {
            int c = rowrook[rookidx].SS;

            ct[NN + c] = i;
            for (int node = (NN+c)/2; node; node /= 2) ct[node] = min(ct[2*node], ct[2*node+1]);

            rookidx++;
        }

        // process queries
        while (queryidx < q && rowquery[queryidx].FF.FF.FF == i) {
            int ln = NN + rowquery[queryidx].FF.SS.FF;
            int rn = NN + rowquery[queryidx].FF.SS.SS;

            int mm = INF;

            while (ln <= rn) {
                if ( (ln & 1)) mm = min(mm, ct[ln]);
                if (!(rn & 1)) mm = min(mm, ct[rn]);

                ln = (ln + 1) / 2;
                rn = (rn - 1) / 2;
            }

            if (mm >= rowquery[queryidx].FF.FF.SS) res[rowquery[queryidx].SS] = 1;

            queryidx++;
        }

        if (i == n && (rookidx != k || queryidx != q)) cout << rookidx << " " << queryidx << endl;
    }

    FOR1(i, q) {
        if (res[i]) printf("YES\n");
        else printf("NO\n");
    }

    return 0;
}


#pragma comment(linker, "/stack:32000000")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <sstream>
#include <stack>
#include <cassert>
#include <string.h>
#include <ctime>

#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define sqr(x) (x)*(x)
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define X first
#define Y second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

struct query {
	int x1, y1, x2, y2;
	query(int x1, int x2, int y1, int y2):x1(x1),x2(x2),y1(y1),y2(y2) {}
};

const int maxn = 100010;

int t[4*maxn];
int N = 100005;
void setval(int p, int val) {
	p += N;
	t[p] = val;
	for(p >>= 1; p; p >>= 1) t[p] = min(t[p+p], t[p+p+1]);
}

const int cinf = 1000000010;

int getmin(int l, int r) {
	int best = cinf;
	for (l += N, r += N; l <= r; l = (l+1)>>1, r = (r-1)>>1)
		best = min(best, min(t[l], t[r]));
	return best;
}

vector<int> solve(vector<pii> pts, vector<query> queries) {
	memset(t, -1, sizeof(t));
	vector<vector<int> > evs(maxn);
	forn(i, sz(pts)) evs[pts[i].X].pb(pts[i].Y);
	vector<vector<int> > qevs(maxn);
	forn(i, sz(queries)) qevs[queries[i].x2].pb(i);
	vector<int> answer(sz(queries));
	forn(curx, maxn) {
		forn(j, sz(evs[curx])) {
			setval(evs[curx][j], curx);
		}
		forn(j, sz(qevs[curx])) {
			int mn = getmin(queries[qevs[curx][j]].y1, queries[qevs[curx][j]].y2);
			answer[qevs[curx][j]] = mn >= queries[qevs[curx][j]].x1;
		}
	}
	return answer;
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n, m, k, q; scanf("%d%d%d%d", &n, &m, &k, &q);
	vector<pii> pts(k);
	forn(i, k) {
		scanf("%d%d", &pts[i].X, &pts[i].Y);
	}
	vector<query> queries;
	forn(i, q) {
		int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		queries.pb(query(x1,x2,y1,y2));
	}
	vector<int> res1 = solve(pts, queries);
	forn(i, k) swap(pts[i].X, pts[i].Y);
	forn(i, q) swap(queries[i].x1, queries[i].y1), swap(queries[i].x2, queries[i].y2);
	vector<int> res2 = solve(pts, queries);
	forn(i, q) if (res1[i] || res2[i]) printf("YES\n"); else printf("NO\n");
	return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
using namespace std;
typedef double db;
typedef unsigned long long ll;
const int M = 20000 + 10;
const int T = 86400;
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
const int N = 1e5 + 10;

struct IntTree {
    vector <int> t;
    int size;
    IntTree() {}
    IntTree(int n) {
        size = 1;
        while (size < n) size *= 2;
        t.assign(2 * size, 0);
    }

    int getMin(int lq, int rq) {
        return getMin(1, size, 2 * size - 1, lq + size - 1,  rq + size - 1);
    }

    int getMin(int v, int l, int r, int lq, int rq) {
        if (max(l, lq) > min(r, rq))
            return N;
        if (lq <= l && r <= rq)
            return t[v];
        int m = (l + r) / 2;
        return min(getMin(2 * v, l, m, lq, rq), getMin(2 * v + 1, m + 1, r, lq, rq));
    }

    void update(int v, int val) {
        v += size - 1;
        t[v] = val;
        v >>= 1;
        while (v) {
            t[v] = min(t[2 * v], t[2 * v + 1]);
            v >>= 1;
        }
    }
};

struct Event {
    bool tp;
    int x;
    int y1, y2;
    int id;
    int x2;

    Event(int x, int y1, int y2, int x2, int id):
        tp(1), x(x), y1(y1), y2(y2), x2(x2), id(id) {}
    Event(int x, int y):
        tp(0), x(x), y1(y) {}

    bool operator < (const Event& t) const {
        return x < t.x;
    }
};

void solve(const vector <pair <int, int> >& lad,
           const vector <pair <int, int> >& lef,
           vector <pair <int, int> >& rig,
           bool* use,
           int n,
           int m) {

    IntTree tree(n);
    vector <Event> ev;
    for (int i = 0; i < lad.size(); ++i)
        ev.push_back(Event(lad[i].second, lad[i].first));
    for (size_t i = 0; i < rig.size(); ++i)
        ev.push_back(Event(rig[i].second, lef[i].first, rig[i].first, lef[i].second, i));
    sort(ev.begin(), ev.end());
    for (size_t i = 0; i < ev.size(); ++i)
        if (ev[i].tp == 0) {
            //cerr << "pos = " << ev[i].y1 << " " << ev[i].x << endl;
            tree.update(ev[i].y1, ev[i].x);
            //printf("L");
        }
        else {
            //printf("Q");
            //cerr << ev[i].y1 << " " << ev[i].y2 << endl;
            //cerr << " min = " << tree.getMin(ev[i].y1, ev[i].y2) << endl;
            use[ev[i].id] = tree.getMin(ev[i].y1, ev[i].y2) >= ev[i].x2;
        }
}

bool use1[N], use2[N];

int main() {
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    vector <pair <int, int> > lad1, lad2;
    vector <pair <int, int> > lef1, rig1, lef2, rig2;

    for (int i = 0; i < k; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        lad1.push_back(make_pair(x, y));
        lad2.push_back(make_pair(y, x));
    }

    for (int i = 0; i < q; ++i) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        lef1.push_back(make_pair(x1, y1));
        rig1.push_back(make_pair(x2, y2));

        lef2.push_back(make_pair(y1, x1));
        rig2.push_back(make_pair(y2, x2));
    }

    solve(lad1, lef1, rig1, use1, n, m);
    solve(lad2, lef2, rig2, use2, m, n);
    for (int i = 0; i < q; ++i)
        if (use1[i] || use2[i])
            printf("YES\n");
        else
           printf("NO\n");
/*
4 3 3 1
1 1
3 2
2 3
1 2 2 3

4 3 3 1
1 1
3 2
2 3
2 1 3 3
*/
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
using namespace std;
typedef double db;
typedef unsigned long long ll;
const int M = 20000 + 10;
const int T = 86400;
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
const int N = 1e5 + 10;

struct IntTree {
    vector <int> t;
    int size;
    IntTree() {}
    IntTree(int n) {
        size = 1;
        while (size < n) size *= 2;
        t.assign(2 * size, 0);
    }

    int getMin(int lq, int rq) {
        return getMin(1, size, 2 * size - 1, lq + size - 1,  rq + size - 1);
    }

    int getMin(int v, int l, int r, int lq, int rq) {
        if (max(l, lq) > min(r, rq))
            return N;
        if (lq <= l && r <= rq)
            return t[v];
        int m = (l + r) / 2;
        return min(getMin(2 * v, l, m, lq, rq), getMin(2 * v + 1, m + 1, r, lq, rq));
    }

    void update(int v, int val) {
        v += size - 1;
        t[v] = val;
        v >>= 1;
        while (v) {
            t[v] = min(t[2 * v], t[2 * v + 1]);
            v >>= 1;
        }
    }
};

struct Event {
    bool tp;
    int x;
    int y1, y2;
    int id;
    int x2;

    Event(int x, int y1, int y2, int x2, int id):
        tp(1), x(x), y1(y1), y2(y2), x2(x2), id(id) {}
    Event(int x, int y):
        tp(0), x(x), y1(y) {}

    bool operator < (const Event& t) const {
        return x < t.x || x == t.x && tp < t.tp;
    }
};

void solve(const vector <pair <int, int> >& lad,
           const vector <pair <int, int> >& lef,
           vector <pair <int, int> >& rig,
           bool* use,
           int n,
           int m) {

    IntTree tree(n);
    vector <Event> ev;
    for (int i = 0; i < lad.size(); ++i)
        ev.push_back(Event(lad[i].second, lad[i].first));
    for (size_t i = 0; i < rig.size(); ++i)
        ev.push_back(Event(rig[i].second, lef[i].first, rig[i].first, lef[i].second, i));
    sort(ev.begin(), ev.end());
    for (size_t i = 0; i < ev.size(); ++i)
        if (ev[i].tp == 0) {
            //cerr << "pos = " << ev[i].y1 << " " << ev[i].x << endl;
            tree.update(ev[i].y1, ev[i].x);
            //printf("L");
        }
        else {
            //printf("Q");
            //cerr << ev[i].y1 << " " << ev[i].y2 << endl;
            //cerr << " min = " << tree.getMin(ev[i].y1, ev[i].y2) << endl;
            use[ev[i].id] = tree.getMin(ev[i].y1, ev[i].y2) >= ev[i].x2;
        }
}

bool use1[N], use2[N];

int main() {
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    vector <pair <int, int> > lad1, lad2;
    vector <pair <int, int> > lef1, rig1, lef2, rig2;

    for (int i = 0; i < k; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        lad1.push_back(make_pair(x, y));
        lad2.push_back(make_pair(y, x));
    }

    for (int i = 0; i < q; ++i) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        lef1.push_back(make_pair(x1, y1));
        rig1.push_back(make_pair(x2, y2));

        lef2.push_back(make_pair(y1, x1));
        rig2.push_back(make_pair(y2, x2));
    }

    solve(lad1, lef1, rig1, use1, n, m);
    solve(lad2, lef2, rig2, use2, m, n);
    for (int i = 0; i < q; ++i)
        if (use1[i] || use2[i])
            printf("YES\n");
        else
           printf("NO\n");
/*
4 3 3 1
1 1
3 2
2 3
1 2 2 3

4 3 3 1
1 1
3 2
2 3
2 1 3 3
*/
    return 0;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
using namespace std;
typedef double db;
typedef unsigned long long ll;
const int N = 2e5 + 10;

struct IntTree {
    vector <int> t;
    int size;
    IntTree() {}
    IntTree(int n) {
        size = 1;
        while (size < n) size *= 2;
        t.assign(2 * size, 0);
    }

    int getMin(int lq, int rq) {
        return getMin(1, size, 2 * size - 1, lq + size - 1,  rq + size - 1);
    }

    int getMin(int v, int l, int r, int lq, int rq) {
        if (max(l, lq) > min(r, rq))
            return N;
        if (lq <= l && r <= rq)
            return t[v];
        int m = (l + r) / 2;
        return min(getMin(2 * v, l, m, lq, rq), getMin(2 * v + 1, m + 1, r, lq, rq));
    }

    void update(int v, int val) {
        v += size - 1;
        t[v] = val;
        v >>= 1;
        while (v) {
            t[v] = min(t[2 * v], t[2 * v + 1]);
            v >>= 1;
        }
    }
};

struct Event {
    bool tp;
    int x;
    int y1, y2;
    int id;
    int x2;

    Event(int x, int y1, int y2, int x2, int id):
        tp(1), x(x), y1(y1), y2(y2), x2(x2), id(id) {}
    Event(int x, int y):
        tp(0), x(x), y1(y) {}

    bool operator < (const Event& t) const {
        return x < t.x || x == t.x && tp < t.tp;
    }
};

void solve(const vector <pair <int, int> >& lad,
           const vector <pair <int, int> >& lef,
           vector <pair <int, int> >& rig,
           bool* use,
           int n,
           int m) {

    IntTree tree(n);
    vector <Event> ev;
    for (int i = 0; i < lad.size(); ++i)
        ev.push_back(Event(lad[i].second, lad[i].first));
    for (size_t i = 0; i < rig.size(); ++i)
        ev.push_back(Event(rig[i].second, lef[i].first, rig[i].first, lef[i].second, i));
    sort(ev.begin(), ev.end());
    for (size_t i = 0; i < ev.size(); ++i)
        if (ev[i].tp == 0) {
            //cerr << "pos = " << ev[i].y1 << " " << ev[i].x << endl;
            tree.update(ev[i].y1, ev[i].x);
            //printf("L");
        }
        else {
            //printf("Q");
            //cerr << ev[i].y1 << " " << ev[i].y2 << endl;
            //cerr << " min = " << tree.getMin(ev[i].y1, ev[i].y2) << endl;
            use[ev[i].id] = tree.getMin(ev[i].y1, ev[i].y2) >= ev[i].x2;
        }
}

bool use1[N], use2[N];

int main() {
    int n, m, k, q;
    cin >> n >> m >> k >> q;
    vector <pair <int, int> > lad1, lad2;
    vector <pair <int, int> > lef1, rig1, lef2, rig2;

    for (int i = 0; i < k; ++i) {
        int x, y;
        scanf("%d%d", &x, &y);
        lad1.push_back(make_pair(x, y));
        lad2.push_back(make_pair(y, x));
    }

    for (int i = 0; i < q; ++i) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        lef1.push_back(make_pair(x1, y1));
        rig1.push_back(make_pair(x2, y2));

        lef2.push_back(make_pair(y1, x1));
        rig2.push_back(make_pair(y2, x2));
    }

    solve(lad1, lef1, rig1, use1, n, m);
    solve(lad2, lef2, rig2, use2, m, n);
    for (int i = 0; i < q; ++i)
        if (use1[i] || use2[i])
            printf("YES\n");
        else
           printf("NO\n");
/*
4 3 3 1
1 1
3 2
2 3
1 2 2 3

4 3 3 1
1 1
3 2
2 3
2 1 3 3
*/
    return 0;
}


/* --- author: enot-the-rockstar ---*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <ctime>
#include <cassert>

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forit(it,v) for(typeof((v).begin()) it = v.begin() ; it != (v).end() ; ++it)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()

static inline unsigned long long rdtsc() { unsigned long long d; __asm__ __volatile__ ("rdtsc" : "=A" (d) ); return d; }

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = (int)1e9;
const dbl eps = 1e-9;

/* --- main part --- */

#define TASK "a"

const int maxn = (int)2e5 + 10;
const int N = 1 << 18;

struct tree
{
    int t[2 * N];

    tree()
    {
        memset(t, 0, sizeof t);
    }

    void clear()
    {
        memset(t, 0, sizeof t);
    }

    inline int get(int l, int r)
    {
        l += N;
        r += N;
        int res = inf;
        while (l <= r)
        {
            if ((l & 1) == 1) res = min(res, t[l]);
            if ((r & 1) == 0) res = min(res, t[r]);
            l = (l + 1) >> 1;
            r = (r - 1) >> 1;
        }
        return res;
    }

    inline void upd(int x, int val)
    {
        x += N;
        t[x] = val;
        while (x > 1)
        {
            x >>= 1;
            t[x] = min(t[2 * x], t[2 * x + 1]);
        }
    }
};

#define y1 sdfkljh
int x[maxn], y[maxn];
int x1[maxn], y1[maxn], x2[maxn], y2[maxn];
int res[maxn];

tree t;

pi e[maxn * 2];
int ec = 0;

int main()
{
    #ifdef home
        assert(freopen(TASK".in", "r", stdin));
        assert(freopen(TASK".out", "w", stdout));
    #endif
    int n, m, k, q;
    scanf("%d%d%d%d", &n, &m, &k, &q);
    forn(i, k) scanf("%d%d", &x[i], &y[i]);
    forn(i, q) scanf("%d%d%d%d", &x1[i], &y1[i], &x2[i], &y2[i]);
    forn(_, 2)
    {
        t.clear();
        ec = 0;
        forn(i, k) e[ec++] = mp(y[i], -i - 1);
        forn(i, q) e[ec++] = mp(y2[i], i + 1);
        sort(e, e + ec);
        forn(i, ec)
        {
            int id = e[i].sc;
            if (id > 0)
            {
                id -= 1;
                if (t.get(x1[id], x2[id]) >= y1[id])
                {
                    res[id] = 1;
                }
            }
            else
            {
                id = -id - 1;
                t.upd(x[id], y[id]);
            }
        }

        forn(i, k) swap(x[i], y[i]);
        forn(i, q)
        {
            swap(x1[i], y1[i]);
            swap(x2[i], y2[i]);
        }
    }
    forn(i, q)
    {
        if (res[i]) printf("YES\n");
        else printf("NO\n");
    }
    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf

using namespace std;

const int maxn = 100020;
const int maxx = 10000;
const int MOd = 1e9+7;
const int K = 750;

typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;

int a, b, c, q, n;
vector <ii> segment[maxn*3], segment2[maxn*3];
vector <int> w[maxn], w2[maxn];

int main() {

	scanf("%d %d %d %d",&a,&b,&c,&q);

	n = 1<<17;

	for(int i=1,j,k;i<=c;i++) {
		scanf("%d %d",&j,&k);
		w[j].pb( k );
		w2[k].pb( j );
	}
	//~ printf("asdad\n");
	for(int i=1;i<=a;i++) {
		int k = b+1;
		sort( all( w[i] ) );
		for(int j=w[i].size()-1;j>=0;j--) {
			segment[i+n-1].pb( ii( w[i][j], k ) );
			//~ printf("%d ===> %d %d\n",i,w[i][j],k);
			k = w[i][j];
		}
		//~ printf("%d ===> %d %d\n",i,0,k);
		segment[i+n-1].pb( ii( 0, k ) );
	}

	//~ printf("asdad %d\n",n);
	for(int i=1;i<=b;i++) {
		int k = a+1;
		sort( all( w2[i] ) );
		for(int j=w2[i].size()-1;j>=0;j--) {
			segment2[i+n-1].pb( ii( w2[i][j], k ) );
			//~ printf("%d ===> %d %d\n",i,w2[i][j],k);
			k = w2[i][j];
		}
		//~ printf("%d ===> %d %d\n",i,0,k);
		segment2[i+n-1].pb( ii( 0, k ) );
		//~ sort( all( segment[i+n-1] ) );
	}

	//~ printf("asdad\n");
	for(int k=n-1;k>=1;k--) {
		for(int j=0;j<segment[k+k].size();j++) segment[k].pb( segment[k+k][j] );
		for(int j=0;j<segment[k+k+1].size();j++) segment[k].pb( segment[k+k+1][j] );
		for(int j=0;j<segment2[k+k].size();j++) segment2[k].pb( segment2[k+k][j] );
		for(int j=0;j<segment2[k+k+1].size();j++) segment2[k].pb( segment2[k+k+1][j] );

	}
	for(int k=n+n-1;k>=1;k--) {
		sort( all( segment[k] ) );
		int t = 0;
		for(int i=0;i<segment[k].size();i++) {
			umax( t, segment[k][i].se );
			segment[k][i].se = t;
		}
		sort( all( segment2[k] ) );
		t = 0;
		for(int i=0;i<segment2[k].size();i++) {
			umax( t, segment2[k][i].se );
			//~ if( k == n ) printf("asdas");
			segment2[k][i].se = t;
		}
	}

	//~ printf("asdad\n");
	while( q-- ) {
		int x1, x2, y1, y2;
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		int h = 1, ans = 0;
		for(int l=x1+n-1,r=x2+n-1;l<=r;l=(l+1)>>1, r=(r-1)>>1) {
			if( l&1 ) {
				int t = lower_bound( all(segment[l]), ii( y1, 0 ) ) - segment[l].begin();
				t--;
				//~ printf("asdad %d %d\n",t,segment[l][t].se);
				if( t >= 0 && segment[l][t].se > y2 ) h = 0;
			}
			if( ~r&1 ) {
				int t = lower_bound( all(segment[r]), ii( y1, 0 ) ) - segment[r].begin();
				//~ printf("asdad %d %d %d\n",t,segment[r][t].fi,segment[r][t].se);
				t--;
				//~ printf("asdad %d %d %d\n",t,segment[r][t].fi,segment[r][t].se);
				if( t >= 0 && segment[r][t].se > y2 ) h = 0;
			}
		}
		if( h ) {
			printf("YES\n");
			continue;
		}
		h = 1;
		for(int l=y1+n-1,r=y2+n-1;l<=r;l=(l+1)>>1, r=(r-1)>>1) {
			if( l&1 ) {
				int t = lower_bound( all(segment2[l]), ii( x1, 0 ) ) - segment2[l].begin();
				t--;
				//~ printf("%d %d\n",t,segment2[l][t].se);
				if( t >= 0 && segment2[l][t].se > x2 ) h = 0;
			}
			if( ~r&1 ) {
				int t = lower_bound( all(segment2[r]), ii( x1, 0 ) ) - segment2[r].begin();
				t--;
				//~ printf("%d %d\n",r,segment2[r][t].se);
				if( t >= 0 && segment2[r][t].se > x2 ) h = 0;
			}
		}
		if( h ) {
			printf("YES\n");
			continue;
		}
		printf("NO\n");
	}

	return 0;
}


#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>

#define F1(x,y,z) for(int x=y;x<z;x++)
#define F2(x,y,z) for(int x=y;x<=z;x++)
#define F3(x,y,z) for(int x=y;x>z;x--)
#define F4(x,y,z) for(int x=y;x>=z;x--)
#define W(x) while(x-->0)
#define SI(x) scanf("%d",&x)
#define pb push_back
#define LL long long

#define AMAX 200005
#define MAX 100005

#define f(c,d) ((1<<(c))*(d))

using namespace std;

struct w{
	int x,y;
} ww[MAX];

bool comx(const w& a,const w& b){
	return a.x<b.x;
}

bool comy(const w& a,const w& b){
	return a.y<b.y;
}

struct e{
	int a,b,c,d,i;
} ee[AMAX];

bool comxx(const e& a,const e& b){
	return a.b<b.b;
}

bool comyy(const e& a,const e& b){
	return a.d<b.d;
}

int n,m,k,q;
int x[18][MAX];
int xx[18][MAX];
bool ans[AMAX];
int ta,tb;

int f1(int a,int b,int c,int d){
	if(f(c,d)==a&&f(c,d+1)==b)return x[c][d];
	c--;
	d=d*2+1;
	if(b<=f(c,d))return f1(a,b,c,d-1);
	if(a>=f(c,d))return f1(a,b,c,d);
	return min(f1(a,f(c,d),c,d-1),f1(f(c,d),b,c,d));
}

int f2(int a,int b,int c,int d){
	if(f(c,d)==a&&f(c,d+1)==b)return xx[c][d];
	c--;
	d=d*2+1;
	if(b<=f(c,d))return f2(a,b,c,d-1);
	if(a>=f(c,d))return f2(a,b,c,d);
	return min(f2(a,f(c,d),c,d-1),f2(f(c,d),b,c,d));
}

int main(){
	SI(n);
	SI(m);
	SI(k);
	SI(q);
	F1(a,0,k){
		SI(ww[a].x);
		SI(ww[a].y);
	}
	F1(a,0,q){
		SI(ee[a].a);
		SI(ee[a].c);
		SI(ee[a].b);
		SI(ee[a].d);
		ee[a].i=a;
	}
	sort(ww,ww+k,comx);
	sort(ee,ee+q,comxx);
	ta=0;
	F1(a,0,q){
		while(ta<k&&ww[ta].x<=ee[a].b){
			tb=ww[ta].y;
			x[0][tb]=ww[ta].x;
			F1(a,1,18){
				tb>>=1;
				x[a][tb]=min(x[a-1][tb<<1],x[a-1][(tb<<1)|1]);
			}
			ta++;
		}
		ans[ee[a].i]|=f1(ee[a].c,ee[a].d+1,17,0)>=ee[a].a;
	}
	sort(ww,ww+k,comy);
	sort(ee,ee+q,comyy);
	ta=0;
	F1(a,0,q){
		while(ta<k&&ww[ta].y<=ee[a].d){
			tb=ww[ta].x;
			xx[0][tb]=ww[ta].y;
			F1(a,1,18){
				tb>>=1;
				xx[a][tb]=min(xx[a-1][tb<<1],xx[a-1][(tb<<1)|1]);
			}
			ta++;
		}
		ans[ee[a].i]|=f2(ee[a].a,ee[a].b+1,17,0)>=ee[a].c;
	}
	F1(a,0,q){
		if(ans[a])printf("YES\n");
		else printf("NO\n");
	}
	//system("pause");
    return 0;
}


#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <deque>
#include <cstring>
#include <functional>
#include <climits>
#include <list>

#define F1(x,y,z) for(int x=y;x<z;x++)
#define F2(x,y,z) for(int x=y;x<=z;x++)
#define F3(x,y,z) for(int x=y;x>z;x--)
#define F4(x,y,z) for(int x=y;x>=z;x--)
#define W(x) while(x-->0)
#define SI(x) scanf("%d",&x)
#define pb push_back
#define LL long long

#define AMAX 200005
#define MAX 100005

#define f(c,d) ((1<<(c))*(d))

using namespace std;

struct w{
	int x,y;
} ww[AMAX];

bool comx(const w& a,const w& b){
	return a.x<b.x;
}

bool comy(const w& a,const w& b){
	return a.y<b.y;
}

struct e{
	int a,b,c,d,i;
} ee[AMAX];

bool comxx(const e& a,const e& b){
	return a.b<b.b;
}

bool comyy(const e& a,const e& b){
	return a.d<b.d;
}

int k,q;
int x[18][MAX];
int xx[18][MAX];
bool ans[AMAX];
int ta,tb;

int f1(int a,int b,int c,int d){
	if(f(c,d)==a&&f(c,d+1)==b)return x[c][d];
	c--;
	d=d*2+1;
	if(b<=f(c,d))return f1(a,b,c,d-1);
	if(a>=f(c,d))return f1(a,b,c,d);
	return min(f1(a,f(c,d),c,d-1),f1(f(c,d),b,c,d));
}

int f2(int a,int b,int c,int d){
	if(f(c,d)==a&&f(c,d+1)==b)return xx[c][d];
	c--;
	d=d*2+1;
	if(b<=f(c,d))return f2(a,b,c,d-1);
	if(a>=f(c,d))return f2(a,b,c,d);
	return min(f2(a,f(c,d),c,d-1),f2(f(c,d),b,c,d));
}

int main(){
	SI(k);
	SI(k);
	SI(k);
	SI(q);
	F1(a,0,k){
		SI(ww[a].x);
		SI(ww[a].y);
	}
	F1(a,0,q){
		SI(ee[a].a);
		SI(ee[a].c);
		SI(ee[a].b);
		SI(ee[a].d);
		ee[a].i=a;
	}
	sort(ww,ww+k,comx);
	sort(ee,ee+q,comxx);
	ta=0;
	F1(a,0,q){
		while(ta<k&&ww[ta].x<=ee[a].b){
			tb=ww[ta].y;
			x[0][tb]=ww[ta].x;
			F1(a,1,18){
				tb>>=1;
				x[a][tb]=min(x[a-1][tb<<1],x[a-1][(tb<<1)|1]);
			}
			ta++;
		}
		ans[ee[a].i]|=f1(ee[a].c,ee[a].d+1,17,0)>=ee[a].a;
	}
	sort(ww,ww+k,comy);
	sort(ee,ee+q,comyy);
	ta=0;
	F1(a,0,q){
		while(ta<k&&ww[ta].y<=ee[a].d){
			tb=ww[ta].x;
			xx[0][tb]=ww[ta].y;
			F1(a,1,18){
				tb>>=1;
				xx[a][tb]=min(xx[a-1][tb<<1],xx[a-1][(tb<<1)|1]);
			}
			ta++;
		}
		ans[ee[a].i]|=f2(ee[a].a,ee[a].b+1,17,0)>=ee[a].c;
	}
	F1(a,0,q){
		if(ans[a])printf("YES\n");
		else printf("NO\n");
	}
	//system("pause");
    return 0;
}


#define filer() freopen("far.in","r",stdin)
#define filew() freopen("far.in","w",stdout)

#include <set>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include <map>
#include<ctime>
#define SET(a, x) memset((a), (x), sizeof(a))
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define i64 ll
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define MAX 200000
#define xx first
#define yy second
using namespace std;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
const int inf=0x20202020;
const ll mod=1000000007;
const double eps=1e-9;
const double pi=3.1415926535897932384626;

const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

template<class X>void debug(vector<X>&v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}

int last[MAX + 9];
int ans[200009];

struct node
{
    int x;
    int y;
    int is_q;
    int xx;
    int yy;
    int id;
};
vector<node>V;

bool cmp1(node a, node b)
{
    if(a.x==b.x)return a.is_q<b.is_q;
    return a.x<b.x;
}

bool cmp2(node a, node b)
{
    if(a.y==b.y)return a.is_q<b.is_q;
    return a.y<b.y;
}

int st[1048580],flag[1048580];
void build(int cur, int s, int e,int val) {
    if(s == e) {
        st[cur] = val;
        flag[cur] = -1;
        return;
    }
    int m = (s+e)>>1, c1 = cur << 1, c2 = c1 | 1;
    build(c1, s, m, val);
    build(c2, m+1, e, val);
    st[cur] = val;
    flag[cur] = -1;
}

void resolve(int cur, bool leaf) {
    if(flag[cur] == -1) return;
    if(!leaf) {
        flag[cur<<1] = flag[cur];
        flag[(cur<<1)|1] = flag[cur];
    }
    st[cur] = flag[cur];
    flag[cur] = -1;
}

// Updates the range [S, E] with value.
void update(int cur, int s, int e, int S, int E, int value) {
    resolve(cur, s == e);
    if(s > E || e < S) return;
    if(s >= S && e <= E) {
        flag[cur] = value;
        resolve(cur, s == e);
        return;
    }
    int m = (s+e)>>1, c1 = cur << 1, c2 = c1 | 1;
    update(c1, s, m, S, E, value);
    update(c2, m+1, e, S, E, value);
    st[cur] = min(st[c1], st[c2]);
}

// Gives the minimum in the range [S, E]
int query(int cur, int s, int e, int S, int E) {
    resolve(cur, s == e);
    if(s > E || e < S) return inf;//it shd return an minimum value for maximaization and vice versa or an invalid value return 0;
    if(s >= S && e <= E) return st[cur];
    int m = (s+e)>>1, c1 = cur << 1, c2 = c1 | 1;
    return min( query(c1, s, m, S, E), query(c2, m+1, e, S, E) );
}

int main()
{
    //filer();

    int i,j,k ,T,cas=0;
    int N,M,K,Q;

    cin>>N>>M>>K>>Q;
    node s;
    for(i=0;i<K;i++)
    {
        scanf("%d%d",&s.x,&s.y);
        s.is_q=0;
        V.pb(s);
    }

    for(i=0;i<Q;i++)
    {
        scanf("%d%d%d%d",&s.xx,&s.yy,&s.x,&s.y);
        s.is_q=1;
        s.id=i;
        V.pb(s);
    }
    int a,b,x,y,id,q;
    sort(all(V),cmp1);
    //SET(last,-1);

    for(i=0;i<SZ(V);i++)
    {
        if(V[i].is_q)
        {
            id=V[i].id;
            a=V[i].yy;
            b=V[i].y;
            q=query(1,1,100000,a,b);
            x=V[i].xx;
            if(q<x)ans[id]=1;
            else ans[id]=0;
        }
        else
        {
            y=V[i].y;
            x=V[i].x;
            update(1,1,100000,y,y,x);
        }

    }
    sort(all(V),cmp2);
    SET(st,0);
    SET(flag,0);
    for(i=0;i<SZ(V);i++)
    {
        if(V[i].is_q)
        {
            id=V[i].id;
            a=V[i].xx;
            b=V[i].x;
            q=query(1,1,100000,a,b);
            y=V[i].yy;
            if(q<y)ans[id]&=1;
            else ans[id]&=0;
        }
        else
        {
            y=V[i].y;
            x=V[i].x;
            update(1,1,100000,x,x,y);
        }
    }
    for(i=0;i<Q;i++)
    {
        if((!ans[i])==0)cout<<"NO\n";
        else cout<<"YES\n";
    }
    return 0;
}
/*Test Cases

*/
/*Test Cases

*/


#define filer() freopen("far.in","r",stdin)
#define filew() freopen("far.in","w",stdout)

#include <set>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include <map>
#include<ctime>
#define SET(a, x) memset((a), (x), sizeof(a))
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define i64 ll
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define MAX 200000
#define xx first
#define yy second
using namespace std;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<double> VD;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
const int inf=0x20202020;
const ll mod=1000000007;
const double eps=1e-9;
const double pi=3.1415926535897932384626;

const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

template<class X>void debug(vector<X>&v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}

int last[MAX + 9];
int ans[200009];

struct node
{
    int x;
    int y;
    int is_q;
    int xx;
    int yy;
    int id;
};
vector<node>V;

bool cmp1(node a, node b)
{
    if(a.x==b.x)return a.is_q<b.is_q;
    return a.x<b.x;
}

bool cmp2(node a, node b)
{
    if(a.y==b.y)return a.is_q<b.is_q;
    return a.y<b.y;
}

int st[1048580],flag[1048580];
void build(int cur, int s, int e,int val) {
    if(s == e) {
        st[cur] = val;
        flag[cur] = -1;
        return;
    }
    int m = (s+e)>>1, c1 = cur << 1, c2 = c1 | 1;
    build(c1, s, m, val);
    build(c2, m+1, e, val);
    st[cur] = val;
    flag[cur] = -1;
}

void resolve(int cur, bool leaf) {
    if(flag[cur] == -1) return;
    if(!leaf) {
        flag[cur<<1] = flag[cur];
        flag[(cur<<1)|1] = flag[cur];
    }
    st[cur] = flag[cur];
    flag[cur] = -1;
}

// Updates the range [S, E] with value.
void update(int cur, int s, int e, int S, int E, int value) {
    resolve(cur, s == e);
    if(s > E || e < S) return;
    if(s >= S && e <= E) {
        flag[cur] = value;
        resolve(cur, s == e);
        return;
    }
    int m = (s+e)>>1, c1 = cur << 1, c2 = c1 | 1;
    update(c1, s, m, S, E, value);
    update(c2, m+1, e, S, E, value);
    st[cur] = min(st[c1], st[c2]);
}

// Gives the minimum in the range [S, E]
int query(int cur, int s, int e, int S, int E) {
    resolve(cur, s == e);
    if(s > E || e < S) return inf;//it shd return an minimum value for maximaization and vice versa or an invalid value return 0;
    if(s >= S && e <= E) return st[cur];
    int m = (s+e)>>1, c1 = cur << 1, c2 = c1 | 1;
    return min( query(c1, s, m, S, E), query(c2, m+1, e, S, E) );
}

int main()
{

    int i,j,k ,T,cas=0;
    int N,M,K,Q;

    cin>>N>>M>>K>>Q;
    node s;
    for(i=0;i<K;i++)
    {
        scanf("%d%d",&s.x,&s.y);
        s.is_q=0;
        V.pb(s);
    }

    for(i=0;i<M;i++)
    {
        scanf("%d%d%d%d",&s.xx,&s.yy,&s.x,&s.y);
        s.is_q=1;
        s.id=i;
        V.pb(s);
    }
    int a,b,x,y,id,q;
    sort(all(V),cmp1);
    //SET(last,-1);

    for(i=0;i<SZ(V);i++)
    {
        if(V[i].is_q)
        {
            id=V[i].id;
            a=V[i].yy;
            b=V[i].y;
            q=query(1,1,100000,a,b);
            x=V[i].xx;
            if(q<x)ans[id]=1;
            else ans[id]=0;
        }
        else
        {
            y=V[i].y;
            x=V[i].x;
            update(1,1,100000,y,y,x);
        }

    }
    sort(all(V),cmp2);
    SET(st,0);
    SET(flag,0);
    for(i=0;i<SZ(V);i++)
    {
        if(V[i].is_q)
        {
            id=V[i].id;
            a=V[i].xx;
            b=V[i].x;
            q=query(1,1,100000,a,b);
            y=V[i].yy;
            if(q<y)ans[id]&=1;
            else ans[id]&=0;
        }
        else
        {
            y=V[i].y;
            x=V[i].x;
            update(1,1,100000,x,x,y);
        }
    }
    for(i=0;i<M;i++)
    {
        if((!ans[i])==0)cout<<"NO\n";
        else cout<<"YES\n";
    }
    return 0;
}
/*Test Cases

*/
/*Test Cases

*/


#include <bits/stdc++.h>
using namespace std;
bool s(double a, double b)
{

    return fabs(a - b) < std::numeric_limits<double>::epsilon();
}
int main()
{
    int n, x0, y0;
    int x, y, c = 0;
    double m[1005];
    cin>>n>>x0>>y0;
    for(int i = 0; i < n; i++)
        { cin>>x>>y;
          if(x==x0) m[i]=x;
          else m[i]=(double)(y-y0)/(x-x0);
        }
        sort(m,m+n);
    for(int i = 0; i < n-1; i++)
    {
        c++;
        while(i<n-1 &&s(m[i],m[i+1]))
             i++;
    }
    if(!s(m[n-2],m[n-1])) c++;
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool s(double a, double b)
{

    return fabs(a - b) < std::numeric_limits<double>::epsilon();
}
int main()
{
    int n, x0, y0;
    int x, y, c = 0, num=0;
    map <double,int> m;
    map <double,int> :: iterator I;
    bool flag=0;
    cin>>n>>x0>>y0;
    for(int i = 0; i < n; i++)
        { cin>>x>>y;
          if(x==x0) flag=1;
          else m[((double)(y-y0))/((double)(x-x0))]=1;
        }
    for(I = m.begin(); I != m.end(); I++) if(I->second)c++;
    cout<<c+flag;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool s(double a, double b)
{

    return fabs(a - b) < std::numeric_limits<double>::epsilon();
}
int main()
{
    int n, x0, y0;
    int x, y, c = 0, num=0;
    double m[1005];
    bool flag=0;
    cin>>n>>x0>>y0;
    for(int i = 0; i < n; i++)
        { cin>>x>>y;
          if(x==x0) flag=1;
          else m[i]=((double)(y-y0))/((double)(x-x0)), num++;
        }
    sort(m,m+num);
    for(int i = 0; i < num-1; i++)
    {
        c++;
        while(i<num-1 &&s(m[i],m[i+1]))
             i++;
    }
    if(!s(m[num-2],m[num-1])) c++;
    cout<<c+flag;
    return 0;
}


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

int main()
{
    int n, x0, y0;
    int x,y;
    bool flag = 0;
    set <float> m;
    cin>>n>>x0>>y0;
    for(int i = 0; i < n; i++)
        { cin>>x>>y;
          if(x==x0) flag = 1;
          else m.insert((float)((y-y0)/(x-x0)));
        }
    if(!flag)cout<<m.size();
    else cout<<m.size()+1;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool s(double a, double b)
{

    return fabs(a - b) < std::numeric_limits<double>::epsilon();
}
int main()
{
    int n, x0, y0;
    int x, y, c = 0;
    float m[1005];
    cin>>n>>x0>>y0;
    for(int i = 0; i < n; i++)
        { cin>>x>>y;
          if(x==x0) m[i]=x;
          else m[i]=(float)(y-y0)/(x-x0);
        }
        sort(m,m+n);
    for(int i = 0; i < n-1; i++)
    {
        c++;
        while(i<n-1 &&s(m[i],m[i+1]))
             i++;
    }
    if(!s(m[n-2],m[n-1])) c++;
    cout<<c;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool s(double a, double b)
{

    return fabs(a - b) < std::numeric_limits<double>::epsilon();
}
int main()
{
    int n, x0, y0;
    int x, y, c = 0;
    double m[1005];
    bool flag=0;
    cin>>n>>x0>>y0;
    for(int i = 0; i < n; i++)
        { cin>>x>>y;
          if(x==x0) flag=1;
          else m[i]=((double)(y-y0))/((double)(x-x0));
        }
    sort(m,m+n);
    for(int i = 0; i < n-1; i++)
    {
        c++;
        while(i<n-1 &&s(m[i],m[i+1]))
             i++;
    }
    if(!s(m[n-2],m[n-1])) c++;
    cout<<c+flag;
    return 0;
}


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

int main(){
    ll N;
    double a,b,c,d;
    double k;
    cin >> N >> a >> b;
    set<ll>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = INF;
            s.insert(q);
            continue;
        }
        if( b == d ){
            ll q = 0;
            s.insert(q);
            continue;
        }
        k = ( d-b )/( c-a );
        cout << k << endl;
        s.insert( (ll)(k*10000)  );
    }
    cout << s.size() << endl;
}


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

int main(){
    ll N;
    double a,b,c,d;
    double k;
    cin >> N;
    cin >> a >> b;
    set<ll>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = INF;
            s.insert(q);
            continue;
        }
        if( b == d ){
            ll q = 0;
            s.insert(q);
            continue;
        }
        k = ( d-b )/( c-a );
        s.insert( (ll)(k*100)  );
    }
    cout << s.size() << endl;
}


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

int main(){
    ll N;
    ll a,b,c,d;
    double k;
    cin >> N;
    cin >> a >> b;
    set<char>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = INF;
            s.insert(q);
            // cout << q << endl;
            continue;
        }
        if( b == d ){
            ll q = 0;
            s.insert(q);
            // cout << q << endl;
            continue;
        }
        k = ( d-b )*1.0/( c-a );
        s.insert( (ll)(k*100)  );
        // cout << k << endl;
    }
    cout << s.size() << endl;
}


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

int main(){
    int N;
    int a,b,c,d;
    double k;
    cin >> N;
    cin >> a >> b;
    set<char>s;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            int q = 0;
            s.insert(q);
            continue;
        }else if( b == d ){
            int q = INF;
            s.insert(q);
            continue;
        }
        k = ( d-b )/( c-a );
        s.insert( (int)(k*100)  );
    }
    cout << s.size()+cnt << endl;

}


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

int main(){
    ll N;
    double a,b,c,d;
    double k;
    cin >> N >> a >> b;
    set<double>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = 0;
            s.insert(0);
            continue;
        }
        if( b == d ){
            ll q = INF;
            s.insert(q);
            continue;
        }
        k = ( c-a )/( d-b );
        // cout << k << endl;
        s.insert( (ll)(k*10000)  );
    }
    cout << s.size() << endl;
}


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

int main(){
    ll N;
    double a,b,c,d;
    double k;
    cin >> N >> a >> b;
    set<double>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = 0;
            s.insert(q);
            continue;
        }
        if( b == d ){
            ll q = INF;
            s.insert(q);
            continue;
        }
        k = ( c-a )/( d-b );
        s.insert( (k)  );
    }
    cout << s.size() << endl;
}


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

int main(){
    ll N;
    double a,b,c,d;
    double k;
    cin >> N;
    cin >> a >> b;
    set<char>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = INF;
            s.insert(q);
            continue;
        }
        if( b == d ){
            ll q = 0;
            s.insert(q);
            continue;
        }
        k = ( d-b )/( c-a );
        s.insert( (ll)(k*100)  );
    }
    cout << s.size() << endl;
}


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

int main(){
    ll N;
    ll a,b,c,d;
    double k;
    cin >> N;
    cin >> a >> b;
    set<char>s;
    ll cnt = 0;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = INF;
            s.insert(q);
            continue;
        }else if( b == d ){
            ll q = 0;
            s.insert(q);
            continue;
        }
        k = ( d-b )/( c-a );
        s.insert( (ll)(k*100)  );
    }
    cout << s.size()+cnt << endl;
}


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

int main(){
    ll N;
    double a,b,c,d;
    double k;
    cin >> N >> a >> b;
    set<double>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = INF;
            s.insert(q);
            continue;
        }
        if( b == d ){
            ll q = 0;
            s.insert(q);
            continue;
        }
        k = ( d-b )/( c-a );
        // cout << k << endl;
        s.insert( (ll)(k*10000)  );
    }
    cout << s.size() << endl;
}


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

int main(){
    int N;
    int a,b,c,d;
    double k;
    cin >> N;
    cin >> a >> b;
    set<char>s;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        scanf("%d%d",&c,&d);
        if( a == c ){
            int q = 0;
            s.insert(q);
            continue;
        }else if( b == d ){
            int q = INF;
            s.insert(q);
            continue;
        }
        k = abs( d-b )/abs( c-a );
        s.insert( (int)(k*100)  );
    }
    cout << s.size()+cnt << endl;

}


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

int main(){
    int N;
    int a,b,c,d;
    double k;
    cin >> N;
    cin >> a >> b;
    set<char>s;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        scanf("%d%d",&c,&d);
        if( a == c ){
            cnt += 1;
            continue;
        }else if( b == d ){
            cnt += 1;
            continue;
        }
        k = abs( d-b )/abs( c-a );
        s.insert( (int)(k*100)  );
    }
    cout << s.size()+cnt << endl;

}


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

int main(){
    ll N;
    double a,b,c,d;
    double k;
    cin >> N;
    cin >> a >> b;
    set<double>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = INF;
            s.insert(q);
            continue;
        }
        if( b == d ){
            ll q = 0;
            s.insert(q);
            continue;
        }
        k = ( d-b )/( c-a );
        s.insert( (ll)(k*100)  );
    }
    cout << s.size() << endl;
}


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

int main(){
    ll N;
    double a,b,c,d;
    double k;
    cin >> N >> a >> b;
    set<ll>s;
    for(ll i = 0; i < N; i++){
        cin >> c >> d;
        if( a == c ){
            ll q = INF;
            s.insert(q);
            continue;
        }
        if( b == d ){
            ll q = 0;
            s.insert(q);
            continue;
        }
        k = ( d-b )/( c-a );
        s.insert( (ll)(k*1000)  );
    }
    cout << s.size() << endl;
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >v;
bool com(pair<int,int>a,pair<int,int>b){
    return abs(a.first-b.first)<abs(a.second-b.second);
}
bool com1(pair<int,int>a,pair<int,int>b){
    return a.first<b.first;
}
bool com2(pair<int,int>a,pair<int,int>b){
    return a.second<b.second;
}
map<int,int>mp;
int main(){
    int n,x0,y0;
    cin>>n>>x0>>y0;
    while(n--){
        int x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
    }
    sort(v.begin(),v.end(),com);
    int cnt=1,cn=0;
    for(int i=1;i<v.size();i++){
        if(abs(v[i].first-v[i-1].first)==abs(v[i].second-v[i-1].second)){
            cnt++;
        }
        else{
            if(cnt>1){
                for(int j=i;j>=i-cnt;i++){
                    mp[i]=1;
                }
                cn++;
            }
                cnt=1;
            }
        }
        int kk=v.size();
        for(int i=0;i<kk;i++){
            if(mp[i]){
                v.erase(v.begin()+i);
            }
        }
        mp.clear();
        sort(v.begin(),v.end(),com1);
        cnt=1;
        for(int i=1;i<v.size();i++){
            if(v[i].first==v[i-1].first)cnt++;
            else{
                if(cnt>1){
                    cn++;
                    for(int j=i;j>=i-cnt;i++){
                        mp[i]=1;
                    }
                    cnt=1;
                }
            }
        }
        kk=v.size();
        for(int i=0;i<kk;i++){
            if(mp[i]){
                v.erase(v.begin()+i);
            }
        }
        sort(v.begin(),v.end(),com2);
        bool ck=0;
        for(int i=1;i<v.size();i++){
            ck=1;
            if(v[i].first==v[i-1].first)cnt++;
            else{
                if(cnt>1){
                    cn++;
                    cnt=1;
                }
            }
        }
        if(ck)cn++;
        cout<<cn<<endl;

    }


#include<bits/stdc++.h>
using namespace std;
map<double,int>mp;
int main(){
    int n;
    double x,y;
    cin>>n>>x>>y;
    int f=0;
    while(n--){
        double x0,y0;
        cin>>x0>>y0;
        if(x!=x0){
            mp[(x-x0)/(y-y0)]++;
        }
        else f=1;
    }
    cout<<mp.size()+f<<endl;
}


#include<bits/stdc++.h>
using namespace std;
set<double>s;
int main()
{
    int n,k=0;
    double x0,y0;
    cin>>n>>x0>>y0;
    for(int i=0; i<n; i++)
    {
        double a,b;
        cin>>a>>b;
        if(a!=x0) s.insert((b-y0)/(a-x0));
        else k=1;
    }

    cout<<s.size()+k;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set<double>s;
int main(){
    int n;
    double x,y;
    cin>>n>>x>>y;
    int f=0;
    while(n--){
        double x0,y0;
        cin>>x0>>y0;
        if(x!=x0){
            s.insert((y-y0)/(x-x0));
        }
        else f=1;
    }
    cout<<s.size()+f<<endl;
}


#include<bits/stdc++.h>
using namespace std;
set<double>s;
int main(){
    int n;
    double x,y,a,b,k=0;
    cin>>n>>x>>y;
    for(int i=0; i<n; i++)
    {
        cin>>a>>b;
        if(y!=b) s.insert((x-a)/(y-b));
        else k=1;
    }
    cout<<s.size()+k<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
set<double>s;
int main(){
    int n;
    double x,y;
    cin>>n>>x>>y;
    int f=0;
    for(int i=0;i<n;i++){
        double x0,y0;
        cin>>x0>>y0;
        if(y!=y0){
            s.insert((y-y0)/(x-x0));
        }
        else f=1;
    }
    cout<<s.size()+f<<endl;
}


#include<bits/stdc++.h>
using namespace std;
set<double>s;
int main(){
    int n;
    double x,y;
    cin>>n>>x>>y;
    int f=0;
    while(n--){
        double x0,y0;
        cin>>x0>>y0;
        if(y!=y0){
            s.insert((y-y0)/(x-x0));
        }
        else f=1;
    }
    cout<<s.size()+f<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long n;
    double x,y,a,b,k=0;
    set<double>s;
    cin>>n>>x>>y;
    for(long i=0; i<n; i++)
    {
        cin>>a>>b;
        if(x!=a) s.insert((y-b)/(x-a));
        else k=1;
    }
    cout<<s.size()+k<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double x,y,a,b,k=0;
    set<double>s;
    cin>>n>>x>>y;
    for(int i=0; i<n; i++)
    {
        cin>>a>>b;
        if(x!=a) s.insert((y-b)/(x-a));
        else k=1;
    }
    cout<<s.size()+k<<endl;
}


#include<bits/stdc++.h>
using namespace std;
set<double>s;
int main(){
    int n;
    double x,y;
    cin>>n>>x>>y;
    int f=0;
    while(n--){
        double x0,y0;
        cin>>x0>>y0;
        if(x!=x0){
            s.insert((x-x0)/(y-y0));
        }
        else f=1;
    }
    cout<<s.size()+f<<endl;
}


#include<bits/stdc++.h>
using namespace std;
set<double>s;
int main(){
    int n;
    double x,y,a,b,k=0;
    cin>>n>>x>>y;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(y!=b) s.insert((x-a)/(y-b));
        else k=1;
    }
    cout<<s.size()+k<<endl;
}


#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >v;
bool com(pair<int,int>a,pair<int,int>b){
    return abs(a.first-b.first)<abs(a.second-b.second);
}
bool com1(pair<int,int>a,pair<int,int>b){
    return a.first<b.first;
}
bool com2(pair<int,int>a,pair<int,int>b){
    return a.second<b.second;
}
map<int,int>mp;
int main(){
    int n,x0,y0;
    cin>>n>>x0>>y0;
    while(n--){
        int x,y;
        cin>>x>>y;
        v.push_back(make_pair(x,y));
    }
    sort(v.begin(),v.end(),com);
    int cnt=1,cn=0;
    for(int i=1;i<v.size();i++){
        if(abs(v[i].first-v[i-1].first)==abs(v[i].second-v[i-1].second)){
            cnt++;
        }
        else{
            if(cnt>1){
                for(int j=i;j>=i-cnt;i++){
                    mp[i]=1;
                }
                cn++;
            }
                cnt=1;
            }
        }
        int kk=v.size();
        for(int i=0;i<kk;i++){
            if(mp[i]){
                v.erase(v.begin()+i);
            }
        }
        mp.clear();
        sort(v.begin(),v.end(),com1);
        cnt=1;
        for(int i=1;i<v.size();i++){
            if(v[i].first==v[i-1].first)cnt++;
            else{
                if(cnt>1){
                    cn++;
                    for(int j=i;j>=i-cnt;i++){
                        mp[i]=1;
                    }
                    cnt=1;
                }
            }
        }
        kk=v.size();
        for(int i=0;i<kk;i++){
            if(mp[i]){
                v.erase(v.begin()+i);
            }
        }
        sort(v.begin(),v.end(),com2);
        bool ck=0;
        for(int i=1;i<v.size();i++){
            ck=1;
            if(v[i].first==v[i-1].first)cnt++;
            else{
                if(cnt>1){
                    cn++;
                    cnt=1;
                }
            }
        }
        if(ck)cn++;
        else if(v.size())cn++;
        cout<<cn<<endl;

    }


#include<bits/stdc++.h>
using namespace std;
main(){
    int n;
    double x0,y0;
    cin>>n>>x0>>y0;
    set<double>a;
    double x,y;
    for(int i=0; i<n; i++){
        cin>>x>>y;
        a.insert((y0-y)/(x0-x));
    }
    cout<<a.size();
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    long n; double x,y,a,b,k=0; set<double>s;cin>>n>>x>>y;
    for(long i=0;i<n;i++){cin>>a>>b;if(y!=b) s.insert((x-a)/(y-b)); else k=1;}
    cout<<s.size()+k;
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int n,x0,y0;
    scanf("%i%i%i",&n,&x0,&y0);
    map<pair<double,double>,bool>a;
    int x,y;
    for(int i=0; i<n; i++){
        scanf("%i%i",&x,&y);
        double k=(double)(y-y0)/(x-x0),
        b=y-k*x;
        a[make_pair(k,b)]=1;
    }
    cout<<a.size();
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int n;
    double x0,y0;
    cin>>n>>x0>>y0;
    set<double>a;
    double x,y;int t=0;
    for(int i=0; i<n; i++){
        cin>>x>>y;
        if(y!=y0)a.insert((y0-y)/(x0-x));
        else t=1;
    }
    cout<<a.size()+t;
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int n;
    double x0,y0;
    cin>>n>>x0>>y0;
    set<double>a;
    double x,y;bool t=0;
    for(int i=0; i<n; i++){
        cin>>x>>y;
        if(y!=y0)a.insert((y0-y)/(x0-x));
        else t=1;
    }
    cout<<a.size()+t;
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int n,x0,y0;
    scanf("%i%i%i",&n,&x0,&y0);
    map<double,bool>a;
    int x,y;
    for(int i=0; i<n; i++){
        scanf("%i%i",&x,&y);
        double k=(double)(y-y0)/(x-x0);
        a[k]=1;
    }
    cout<<a.size();
}


#include<bits/stdc++.h>
using namespace std;
main(){
    int n,x0,y0;
    scanf("%i%i%i",&n,&x0,&y0);
    map<pair<long double,long double>,bool>a;
    int x,y;
    for(int i=0; i<n; i++){
        scanf("%i%i",&x,&y);
        long double k=(double)(y-y0)/(x-x0),
        b=y-k*x;
        a[make_pair(k,b)]=1;
    }
    cout<<a.size();
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll   long long
#define mod 1000000007
#define MOD 1000003
ll powmod(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
int n, c, d;
double x, y, a, b, ans;
set<double>arr;
int main()
{
	cin >> n >> x >> y;
	while (n--)
	{
		cin >> a >> b;
		if (a == x)c = 1;
		else if (y == b)d = 1;
		else arr.insert((b - y) / (a - x));
	}
	cout << arr.size()+c+d<< endl;
	//system("pause");
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll   long long
#define mod 1000000007
#define MOD 1000003
ll powmod(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
int n;
double x, y, a, b, ans, add;
set<double>arr;
int main()
{
	cin >> n >> x >> y;
	while (n--)
	{
		cin >> a >> b;
		if (a == x || y==b)add = 1;
		else arr.insert((b - y) / (a - x));
	}
	cout << arr.size()+add<< endl;
	//system("pause");
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll   long long
#define mod 1000000007
#define MOD 1000003
ll powmod(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
int n, x, y, a, b, arr[10000], ans;

int main()
{
	cin >> n >> x >> y;
	while (n--)
	{
		cin >> a >> b;

		int tmp=abs(a-x)==0?0: abs(b - y) / abs(a - x);
		if (arr[tmp] == 0){ arr[tmp] = 1; ++ans; }
	}
	cout << ans << endl;
	//system("pause");
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll   long long
#define mod 1000000007
#define MOD 1000003
ll powmod(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
int n;
double x, y, a, b, ans;
set<double>arr;
bool is = false;
int main()
{
	cin >> n >> x >> y;
	while (n--)
	{
		cin >> a >> b;
		if (abs(a - b) == 0)is = true;
		else arr.insert((b - y) / (a - x));
	}
	cout << arr.size()+is<< endl;
	//system("pause");
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll   long long
#define mod 1000000007
#define MOD 1000003
ll powmod(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
int n;
double x, y, a, b, ans;
map<double, bool >arr;

int main()
{
	cin >> n >> x >> y;
	while (n--)
	{
		cin >> a >> b;

		int tmp=abs(a-x)==0?0: (b - y) / (a - x);
		if (abs(a-x)==0)
		if (arr[tmp] == 0){ arr[tmp] = 1; ++ans; }
	}
	cout << ans << endl;
	//system("pause");
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll   long long
#define mod 1000000007
#define MOD 1000003
ll powmod(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
int n, x, y, a, b, ans;
map<int, bool >arr;

int main()
{
	cin >> n >> x >> y;
	while (n--)
	{
		cin >> a >> b;

		int tmp=abs(a-x)==0?0: (b - y) / (a - x);
		//cout << tmp << endl;
		if (arr[tmp] == 0){ arr[tmp] = 1; ++ans; }
	}
	cout << ans << endl;
	//system("pause");
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll   long long
#define mod 1000000007
#define MOD 1000003
ll powmod(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
int n;
double x, y, a, b, ans;
map<double, bool >arr;

int main()
{
	cin >> n >> x >> y;
	while (n--)
	{
		cin >> a >> b;

		int tmp=abs(a-x)==0?0: (b - y) / (a - x);
		if (arr[tmp] == 0){ arr[tmp] = 1; ++ans; }
	}
	cout << ans << endl;
	//system("pause");
}


#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define ll   long long
#define mod 1000000007
#define MOD 1000003
ll powmod(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1){ if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
int n;
double x, y, a, b, ans;
set<double>arr;
bool is = false;
int main()
{
	cin >> n >> x >> y;
	while (n--)
	{
		cin >> a >> b;
		if (abs(a - x) == 0)is = true;
		else arr.insert((b - y) / (a - x));
	}
	cout << arr.size()+is<< endl;
	//system("pause");
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      double k;
      if (a[i].first.first - x != 0) {
        k = (a[i].first.second - y) * 1. / (a[i].first.first - x);
        for (int j = i + 1; j < n; j++) {
          if (a[j].first.second - y - k * (a[j].first.first - x) < 0.1) a[j].second = false;
        }
      }
      else {
        for (int j = i + 1; j < n; j++) {
          if (a[j].first.first == x) a[j].second = false;
        }
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      bool check = false;
      double k;
      if (a[i].first.first - x != 0) k = (a[i].first.second - y) * 1. / (a[i].first.first - x);
      else check = true;
      for (int j = i + 1; j < n; j++) {
        if (check && a[j].first.first == x) a[j].second = false;
        else if (a[j].first.second - y == k * (a[j].first.first - x)) a[j].second = false;
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n - 1; i++) {
    if (a[i].second) {
      double k = (a[i].first.second - y) *1. / (a[i].first.first - x);
      for (int j = i + 1; j < n; j++) {
        if (a[j].first.second - y == k * (a[j].first.first - x)) a[j].second = false;
      }
      count++;
    }
  }
  printf("%d", count == 0 ? 1 : count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      double k;
      if (a[i].first.first - x != 0) {
        k = (a[i].first.second - y) * 1. / (a[i].first.first - x);
        for (int j = i + 1; j < n; j++) {
          if (abs(a[j].first.second - y - k * (a[j].first.first - x)) < 0.00000001) a[j].second = false;
        }
      }
      else {
        for (int j = i + 1; j < n; j++) {
          if (a[j].first.first == x) a[j].second = false;
        }
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      bool check = false;
      double k;
      if (a[i].first.first - x != 0) {
        k = (a[i].first.second - y) * 1. / (a[i].first.first - x);
        for (int j = i + 1; j < n; j++) {
          if (a[j].first.second - y == k * (a[j].first.first - x)) a[j].second = false;
        }
      }
      else {
        for (int j = i + 1; j < n; j++) {
          if (check && a[j].first.first == x) a[j].second = false;
        }
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
  pair<pair<int, int>, bool> a[1000];
  int n, x, y, count = 0;
  scanf("%d %d %d", &n, &x, &y);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first.first, &a[i].first.second);
    a[i].second = true;
  }
  for (int i = 0; i < n; i++) {
    if (a[i].second) {
      double k;
      if (a[i].first.first - x != 0) {
        k = (a[i].first.second - y) * 1. / (a[i].first.first - x);
        for (int j = i + 1; j < n; j++) {
          if (abs(a[j].first.second - y - k * (a[j].first.first - x)) < 0.1) a[j].second = false;
        }
      }
      else {
        for (int j = i + 1; j < n; j++) {
          if (a[j].first.first == x) a[j].second = false;
        }
      }
      count++;
    }
  }
  printf("%d", count);
  return 0;
}