#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define _CRT_SECURE_NO_WARNINGS
#define endl '\n'
#define time clock_t tStart = clock();
#define show printf("Time taken: %.6fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define loop(a,b) for(int i=a;i<=b;++i)
#define count_1(n) __builtin_popcountll(n)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define MOD 1000000007
#define itoc(c) ((char)(((int)'0')+c))
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mid(s,e) (s+(e-s)/2)
#define tcase() ll t,n; cin>>t;n=t; while(t--)
#define eb emplace_back
#define ull unsigned long long
#define minimize INT_MAX
#define maximize INT_MIN
#define dsort(a) sort(a.begin(), a.end(), greater<int>())
#define fr(i,n) for(ll i=0; i<n; i++)
#define fr1(i,n) for(ll i=1; i<=n; i++)
#define vp(n) vector<pair<int,int>>v(n);
void fast(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//cout.setf(ios::fixed);
//cout.precision(20);
#ifndef _offline
// freopen("mex.in", "r", stdin);
//freopen("output.txt", "w", stdout);
#endif
}
void HaXn() {
int n,m;
cin >> n >>m;
vector<pair<ll,ll>>v(n);
fr(i,n){
cin >> v[i].F >> v[i].S;
if (v[i].F >v[i].S){
swap(v[i].F, v[i].S);
}
}
sort(v.begin(),v.end());
ll start = v[0].F;
ll end = v[0].S;
vector<pair<ll,ll>>ans;
for (int i =1; i<n; i++){
if (v[i].F > end){
ans.push_back({start,end});
start = v[i].F;
end = v[i].S;
}else{
end = max(end,v[i].S);
}
}
ans.push_back({start,end});
int t; cin >> t;
while (t--){
int l ,r; cin >>l >>r;
if (l>r) swap(l,r);
bool check = false;
for (int i =0; i<ans.size(); i++){
if (l>=ans[i].F && r<=ans[i].S){
check = true;
}
}
if (check) cout << "YES" << endl;
else cout<<"NO" << endl;
}
}
int main() {
fast();
HaXn();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNtYXRoPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsICAgICAgICAgICAgICAgICAgICAgbG9uZyBsb25nCiNkZWZpbmUgX0NSVF9TRUNVUkVfTk9fV0FSTklOR1MKI2RlZmluZSBlbmRsICAgICAgICAgICAgICAgICAgICdcbicKI2RlZmluZSB0aW1lIGNsb2NrX3QgdFN0YXJ0ID0gY2xvY2soKTsKI2RlZmluZSBzaG93IHByaW50ZigiVGltZSB0YWtlbjogJS42ZnNcbiIsIChkb3VibGUpKGNsb2NrKCkgLSB0U3RhcnQpL0NMT0NLU19QRVJfU0VDKTsKI2RlZmluZSBsb29wKGEsYikgICAgICAgICAgICAgZm9yKGludCBpPWE7aTw9YjsrK2kpCiNkZWZpbmUgY291bnRfMShuKSAgICAgICAgICAgIF9fYnVpbHRpbl9wb3Bjb3VudGxsKG4pCiNkZWZpbmUgcGIgICAgICAgICAgICAgICAgICAgIHB1c2hfYmFjawojZGVmaW5lIEYgICAgICAgICAgICAgICAgICAgICBmaXJzdAojZGVmaW5lIFMgICAgICAgICAgICAgICAgICAgICBzZWNvbmQKI2RlZmluZSBtcCAgICAgICAgICAgICAgICAgICAgbWFrZV9wYWlyCiNkZWZpbmUgTU9EICAgICAgICAgICAgICAgICAgIDEwMDAwMDAwMDcKI2RlZmluZSBpdG9jKGMpICAgICAgICAgICAgICAgKChjaGFyKSgoKGludCknMCcpK2MpKQojZGVmaW5lIHZpICAgICAgICAgICAgICAgICAgICB2ZWN0b3I8aW50PgojZGVmaW5lIHZsbCAgICAgICAgICAgICAgICAgICB2ZWN0b3I8bGw+CiNkZWZpbmUgcGxsICAgICAgICAgICAgICAgICAgIHBhaXI8bGwsbGw+CiNkZWZpbmUgcGlpICAgICAgICAgICAgICAgICAgIHBhaXI8aW50LGludD4KI2RlZmluZSBhbGwodikgICAgICAgICAgICAgICAgdi5iZWdpbigpLHYuZW5kKCkKI2RlZmluZSBtaWQocyxlKSAgICAgICAgICAgICAgKHMrKGUtcykvMikKI2RlZmluZSB0Y2FzZSgpICAgICAgICAgICAgICAgbGwgdCxuOyBjaW4+PnQ7bj10OyB3aGlsZSh0LS0pCiNkZWZpbmUgZWIgICAgICAgICAgICAgICAgICAgIGVtcGxhY2VfYmFjawojZGVmaW5lIHVsbCAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBsb25nIGxvbmcKI2RlZmluZSBtaW5pbWl6ZSAgICAgICAgICAgICAgSU5UX01BWAojZGVmaW5lIG1heGltaXplICAgICAgICAgICAgICBJTlRfTUlOCiNkZWZpbmUgZHNvcnQoYSkgICAgICAgICAgICAgIHNvcnQoYS5iZWdpbigpLCBhLmVuZCgpLCBncmVhdGVyPGludD4oKSkKI2RlZmluZSBmcihpLG4pICAgICAgICAgICAgICAgZm9yKGxsIGk9MDsgaTxuOyBpKyspCiNkZWZpbmUgZnIxKGksbikgICAgICAgICAgICAgIGZvcihsbCBpPTE7IGk8PW47IGkrKykKI2RlZmluZSB2cChuKSAgICAgICAgICAgICAgICB2ZWN0b3I8cGFpcjxpbnQsaW50Pj52KG4pOwogCiAKdm9pZCBmYXN0KCl7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGNvdXQudGllKDApOwogICAgLy9jb3V0LnNldGYoaW9zOjpmaXhlZCk7CiAgICAvL2NvdXQucHJlY2lzaW9uKDIwKTsKICAgICNpZm5kZWYgX29mZmxpbmUKICAgIC8vIGZyZW9wZW4oIm1leC5pbiIsICJyIiwgc3RkaW4pOwogICAgLy9mcmVvcGVuKCJvdXRwdXQudHh0IiwgInciLCBzdGRvdXQpOwogICAgI2VuZGlmCn0KIAp2b2lkIEhhWG4oKSB7CiAgaW50IG4sbTsKICBjaW4gPj4gbiA+Pm07CiAKICB2ZWN0b3I8cGFpcjxsbCxsbD4+dihuKTsKICBmcihpLG4pewogICAgICBjaW4gPj4gdltpXS5GID4+IHZbaV0uUzsKICAgICAgaWYgKHZbaV0uRiA+dltpXS5TKXsKICAgICAgICAgIHN3YXAodltpXS5GLCB2W2ldLlMpOwogICAgICB9CiAgfQogIHNvcnQodi5iZWdpbigpLHYuZW5kKCkpOwogIGxsIHN0YXJ0ID0gdlswXS5GOwogIGxsIGVuZCA9IHZbMF0uUzsKICB2ZWN0b3I8cGFpcjxsbCxsbD4+YW5zOwogICAgZm9yIChpbnQgaSA9MTsgaTxuOyBpKyspewogICAgICAgIGlmICh2W2ldLkYgPiBlbmQpewogICAgICAgICAgICBhbnMucHVzaF9iYWNrKHtzdGFydCxlbmR9KTsKICAgICAgICAgICAgc3RhcnQgPSB2W2ldLkY7CiAgICAgICAgICAgIGVuZCA9IHZbaV0uUzsKICAgICAgICB9ZWxzZXsKICAgICAgICAgICAgZW5kID0gbWF4KGVuZCx2W2ldLlMpOwogICAgICAgIH0KICAgIH0KICAgIGFucy5wdXNoX2JhY2soe3N0YXJ0LGVuZH0pOwogICAgCiAgICBpbnQgdDsgY2luID4+IHQ7CiAgICB3aGlsZSAodC0tKXsKICAgICAgICBpbnQgbCAscjsgY2luID4+bCA+PnI7CiAgICAgICAgaWYgKGw+cikgc3dhcChsLHIpOwogICAgICAgIGJvb2wgY2hlY2sgPSBmYWxzZTsKICAgICAgICBmb3IgKGludCBpID0wOyBpPGFucy5zaXplKCk7IGkrKyl7CiAgICAgICAgICAgIGlmIChsPj1hbnNbaV0uRiAmJiByPD1hbnNbaV0uUyl7CiAgICAgICAgICAgICAgICBjaGVjayA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGNoZWNrKSBjb3V0IDw8ICJZRVMiIDw8IGVuZGw7CiAgICAgICAgZWxzZSBjb3V0PDwiTk8iIDw8IGVuZGw7CiAgICB9CiAKfQogCmludCBtYWluKCkgewogICAgZmFzdCgpOwogICAgSGFYbigpOwp9