#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 MOD 1000000007
#define itoc(c) ((char)(((int)'0')+c))
#define V vector<int>
#define Vl vector<ll>
#define pll pair<ll,ll>
#define Vp vector<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);
#define si set <int>
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--){
ll l ,r; cin >>l >>r;
if (l>r) swap(l,r);
pair<ll,ll>p;
p.first =l;
p.second = INT_MAX;
auto it = upper_bound(ans.begin(), ans.end() , p);
if (it != ans.begin()){
it --;
if ((l >= it->first && l <= it->second) && (r <= it->second && r >= it->first)){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
}
}
int main() {
fast();
HaXn();
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGNtYXRoPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsICAgICAgICAgICAgICAgICAgICAgbG9uZyBsb25nCiNkZWZpbmUgX0NSVF9TRUNVUkVfTk9fV0FSTklOR1MKI2RlZmluZSBlbmRsICAgICAgICAgICAgICAgICAgICdcbicKI2RlZmluZSB0aW1lIGNsb2NrX3QgdFN0YXJ0ID0gY2xvY2soKTsKI2RlZmluZSBzaG93IHByaW50ZigiVGltZSB0YWtlbjogJS42ZnNcbiIsIChkb3VibGUpKGNsb2NrKCkgLSB0U3RhcnQpL0NMT0NLU19QRVJfU0VDKTsKI2RlZmluZSBsb29wKGEsYikgICAgICAgICAgICAgZm9yKGludCBpPWE7aTw9YjsrK2kpCiNkZWZpbmUgY291bnRfMShuKSAgICAgICAgICAgIF9fYnVpbHRpbl9wb3Bjb3VudGxsKG4pCiNkZWZpbmUgcGIgICAgICAgICAgICAgICAgICAgIHB1c2hfYmFjawojZGVmaW5lIEYgICAgICAgICAgICAgICAgICAgICBmaXJzdAojZGVmaW5lIFMgICAgICAgICAgICAgICAgICAgICBzZWNvbmQKI2RlZmluZSBNT0QgICAgICAgICAgICAgICAgICAgMTAwMDAwMDAwNwojZGVmaW5lIGl0b2MoYykgICAgICAgICAgICAgICAoKGNoYXIpKCgoaW50KScwJykrYykpCiNkZWZpbmUgViAgICAgICAgICAgICAgICAgICAgIHZlY3RvcjxpbnQ+CiNkZWZpbmUgVmwgICAgICAgICAgICAgICAgICAgICAgdmVjdG9yPGxsPgojZGVmaW5lIHBsbCAgICAgICAgICAgICAgICAgICBwYWlyPGxsLGxsPgojZGVmaW5lIFZwICAgICAgICAgICAgICAgICAgICB2ZWN0b3I8cGFpcjxpbnQsaW50Pj4KI2RlZmluZSBhbGwodikgICAgICAgICAgICAgICAgdi5iZWdpbigpLHYuZW5kKCkKI2RlZmluZSBtaWQocyxlKSAgICAgICAgICAgICAgKHMrKGUtcykvMikKI2RlZmluZSB0Y2FzZSgpICAgICAgICAgICAgICAgbGwgdCxuOyBjaW4+PnQ7bj10OyB3aGlsZSh0LS0pCiNkZWZpbmUgZWIgICAgICAgICAgICAgICAgICAgIGVtcGxhY2VfYmFjawojZGVmaW5lIHVsbCAgICAgICAgICAgICAgICAgICB1bnNpZ25lZCBsb25nIGxvbmcKI2RlZmluZSBtaW5pbWl6ZSAgICAgICAgICAgICAgSU5UX01BWAojZGVmaW5lIG1heGltaXplICAgICAgICAgICAgICBJTlRfTUlOCiNkZWZpbmUgZHNvcnQoYSkgICAgICAgICAgICAgIHNvcnQoYS5iZWdpbigpLCBhLmVuZCgpLCBncmVhdGVyPGludD4oKSkKI2RlZmluZSBmcihpLG4pICAgICAgICAgICAgICAgZm9yKGxsIGk9MDsgaTxuOyBpKyspCiNkZWZpbmUgZnIxKGksbikgICAgICAgICAgICAgIGZvcihsbCBpPTE7IGk8PW47IGkrKykKI2RlZmluZSB2cChuKSAgICAgICAgICAgICAgICB2ZWN0b3I8cGFpcjxpbnQsaW50Pj52KG4pOwojZGVmaW5lIHNpICAgICAgICAgICAgICAgICAgIHNldCA8aW50PgogCiAKIAp2b2lkIGZhc3QoKXsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CiAgICBjaW4udGllKDApOwogICAgY291dC50aWUoMCk7CiAgICAvL2NvdXQuc2V0Zihpb3M6OmZpeGVkKTsKICAgIC8vY291dC5wcmVjaXNpb24oMjApOwogICAgI2lmbmRlZiBfb2ZmbGluZQogICAgLy8gZnJlb3BlbigibWV4LmluIiwgInIiLCBzdGRpbik7CiAgICAvL2ZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiAgICAjZW5kaWYKfQp2b2lkIEhhWG4oKSB7CiAgICBpbnQgbixtOwogICAgY2luID4+IG4gPj5tOwogCiAgICB2ZWN0b3I8cGFpcjxsbCxsbD4+dihuKTsKICAgIGZyKGksbil7CiAgICAgICAgY2luID4+IHZbaV0uRiA+PiB2W2ldLlM7CiAgICAgICAgaWYgKHZbaV0uRiA+dltpXS5TKXsKICAgICAgICAgICAgc3dhcCh2W2ldLkYsIHZbaV0uUyk7CiAgICAgICAgfQogICAgfQogICAgc29ydCh2LmJlZ2luKCksdi5lbmQoKSk7CiAgICBsbCBzdGFydCA9IHZbMF0uRjsKICAgIGxsIGVuZCA9IHZbMF0uUzsKICAgIHZlY3RvcjxwYWlyPGxsLGxsPj5hbnM7CiAgICBmb3IgKGludCBpID0xOyBpPG47IGkrKyl7CiAgICAgICAgaWYgKHZbaV0uRiA+IGVuZCl7CiAgICAgICAgICAgIGFucy5wdXNoX2JhY2soe3N0YXJ0LGVuZH0pOwogICAgICAgICAgICBzdGFydCA9IHZbaV0uRjsKICAgICAgICAgICAgZW5kID0gdltpXS5TOwogICAgICAgIH1lbHNlewogICAgICAgICAgICBlbmQgPSBtYXgoZW5kLHZbaV0uUyk7CiAgICAgICAgfQogICAgfQogICAgYW5zLnB1c2hfYmFjayh7c3RhcnQsZW5kfSk7CiAKICAgIGludCB0OyBjaW4gPj4gdDsKICAgIHdoaWxlICh0LS0pewogICAgICAgIGxsIGwgLHI7IGNpbiA+PmwgPj5yOwogICAgICAgIGlmIChsPnIpIHN3YXAobCxyKTsKICAgICAgICAgcGFpcjxsbCxsbD5wOwogICAgICAgICBwLmZpcnN0ID1sOwogICAgICAgICBwLnNlY29uZCA9IElOVF9NQVg7CiAgICAgICAgYXV0byBpdCA9IHVwcGVyX2JvdW5kKGFucy5iZWdpbigpLCBhbnMuZW5kKCkgLCBwKTsKIAogICAgICAgIGlmIChpdCAhPSBhbnMuYmVnaW4oKSl7CiAgICAgICAgIGl0IC0tOwogICAgICAgIGlmICgobCA+PSBpdC0+Zmlyc3QgJiYgbCA8PSBpdC0+c2Vjb25kKSAmJiAociA8PSBpdC0+c2Vjb25kICYmIHIgPj0gaXQtPmZpcnN0KSl7CiAgICAgICAgICAgIGNvdXQgPDwgIllFUyIgPDwgZW5kbDsKICAgICAgICB9ZWxzZXsKICAgICAgICAgICAgY291dCA8PCAiTk8iIDw8IGVuZGw7CiAgICAgICAgfQogICAgICAgIH0KIAogICAgfQogCn0KIAppbnQgbWFpbigpIHsKICAgIGZhc3QoKTsKICAgIEhhWG4oKTsKIAogCn0=