#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector C(N); for(int i=0; i> a,a--; C.at(a)++; } vector N0(N,N),N1(N,N); for(int i=N; i--;){ if(i < N-1) N0.at(i) = N0.at(i+1),N1.at(i) = N1.at(i+1); if(C.at(i) == 0) N0.at(i) = i; if(C.at(i) == 1) N1.at(i) = i; } int Q; cin >> Q; while(Q--){ int l1,r1,l2,r2; cin >> l1 >> r1 >> l2 >> r2,l1--,l2--,r1--,r2--; if(l1 > l2) swap(l1,l2),swap(r1,r2); else if(l1 == l2 && r1 > r2) swap(r1,r2); int L = max(l1,l2),R = min(r1,r2); bool yes = true; if(N0.at(l1) <= r1) yes = false; if(N0.at(l2) <= r2) yes = false; if(N1.at(L) <= R) yes = false; if(yes) cout << "Yes\n"; else cout << "No\n"; } }