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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pii pair<int, int>
#define fo(i, n) for(i=0; i<n; i++)
typedef tree< pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> mset;
struct os{
	mset A;
	int T;
	#define ook order_of_key
	#define fbo find_by_order
	#define INF INT_MAX
	#define var int
	os(){
		T = 0;
	}
	//add x to set
	void add(var x){
		A.insert({x, ++T});
	}
 
	//no of elements in set between [l,r]
	int count(int l, int r){
		int no = A.ook({r, INF});
		no -= A.ook({l, 0});
		return no;
	}
	//erase x from set
	void erase(var x){
		A.erase(A.lower_bound({x, 0}));
	}
	//get random element from set
	var rnd(int del = 0){
		int n = A.size();
		int pos = rand()%n;
		pair<var,int> x = *(A.fbo(pos));
		if(del) erase(x.first);
		return x.first;
	}
};
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const ll mod = 1000000007;
const ll mod2 = 1000000007 * 1LL * 1000000007;
const int N = 3e5, M = N;
void MOD2(ll &x){
	if(x >= mod2) x-=mod2;
	if(x<0) x+=mod2;
}
//=======================

vi g[N];
int a[N], A[N], n;
ll sum[N];
int bit[20][N], pre[N];
map<ll, ll> h, rev;
set<int> pos[N];
os my[N];
int hai(int no, int x, int y){
	if(pos[no].empty()) return 0;
	auto it = pos[no].lower_bound(x);
	if(it == pos[no].end()) return 0;
	int at = *it;
	if(at <= y) return 1;
	return 0;
}
ll r(){
	return rand()*32000LL+rand();	
}
void add(int pos, int val){
	while(pos<N){
		my[pos].add(val);
		pos += pos&(-pos);
	}
}
int query(int pos, int val){
	int ans = 0;
	while(pos){
		ans += my[pos].count(0, val);
		pos -= pos&(-pos);
	}
	return ans;
}
int renk(int x, int l, int r){
	return query(r, x) - query(l-1, x);	
}
void precompute(){
	int i, j;	
	Fo(i, 1, n+1) {
		add(i, A[i]);
		pos[A[i]].insert(i);
		if(h[A[i]]) continue;
		h[A[i]] = (r()*3200LL+r())%mod2;
		rev[h[A[i]]] = A[i];
		
	}
	sum[0] = pre[0] = 0;
	Fo(i, 1, n+1){
		MOD2(sum[i] = h[A[i]]+sum[i-1]);
		pre[i] = pre[i-1]^A[i];
		int no = A[i];
		Fo(j, 0, 20){
			if( (1<<j) & no ){
				bit[j][i] = no;
			}
		}
	}
	Fo(j, 0, 20)
	Fo(i, 1, n+1) bit[j][i] ^= bit[j][i-1];
	
}

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x <<", " <<#y << "="<< y << endl
void solve(){
	int i, q, a, b, c, d, k, j;
	cin >> n >> q;
	Fo(i, 1, n+1) cin >> A[i], pos[A[i]].clear(), my[i].A.clear(), my[i].T = 0, sum[i] = 0;
	fo(j, 20)
	Fo(i, 1, n+1) bit[j][i] = 0;
	h.clear();
	rev.clear();
	precompute();
	
	// Fo(i, 1, n+1) cout << h[A[i]] << " "; cout << endl;
	
	while(q--){
		cin >> a >> b >> c >> d;
		ll h1, h2;
		MOD2(h1 = sum[b] - sum[a-1]);
		MOD2(h2 = sum[d] - sum[c-1]);
		// deb2(h1, h2);
		if(h1 == h2){
			cout << "YES\n";
			continue;
		}
		
		int x1 = pre[b] ^ pre[a-1];
		int x2 = pre[d] ^ pre[c-1];
		int xy = x1 ^ x2;
		// deb2(x1,x2);
		// deb(xy);
		if(xy == 0){
			cout << "NO\n";
			continue;
		}
		Fo(k, 0, 30){
			if( xy & (1<<k) ) break;
		}
		int p1 = bit[k][b] ^ bit[k][a-1];
		int p2 = bit[k][d] ^ bit[k][c-1];
		// deb(k);
		// deb2(p1, p2);
		
		int no = p1^p2;
		if(no == 0) {
			cout << "NO\n";
			continue;
		}
		// deb(no);
		int f1 = hai(no, a, b);
		int f2 = hai(no, c, d);
		int check = f1 + f2;
		if(check == 0) {
			cout << "NO\n";
			continue;
		}
		int poss = 1;
		
		// deb2(f1,f2);
		if(!f1) swap(a, c), swap(b, d), swap(h1, h2);
		
		//YAHA SE >>>>>>>>>>>>>>>>>>>>>>>>
		//a,b mei hai
		ll com;
		MOD2(com = h1 - h[no]);
		
		ll other_ki_hash ;
		MOD2(other_ki_hash = h2 - com);
		// deb2(com, other_ki_hash);
		int other_no = rev[other_ki_hash];
		// deb(other_no);
		if(other_no == 0){
			poss = 0;
			// cout <<"NO\n";
			// continue;
		}
		int ff = other_no^no;
		// deb(ff);
		if(ff != xy){
			poss = 0;
			// cout <<"NO\n";
			// continue;
		}
		// deb(other_no);
		if(hai(other_no, c, d)){
			//so we solved some other variant of problem
			//for current problem,
			// check for renk
			int e1 = 0, e2 = 0;
			// deb2(no, other_no);
			int jno = no, jother = other_no;
			if(no>other_no) jno--, e1 = 1;
			else if(no<other_no) jother--, e2 = 1;
			int r1 = e1+renk(jno, a, b);
			int r2 = e2+renk(jother, c, d);
			// deb2(e1,e2);
			// deb2(r1,r2);
			if(r1==r2){
				poss = 1;
				// cout << "YES\n";
			}
			else{
				poss = 0;
				// cout <<"NO\n";
			}
		}
		else{
			poss = 0;
			// cout <<"NO\n";
		}
		//YAHA TAK >>>>>>>>>>>>>>>>>>>>>
		//MAINE DALA <<<<<<<<<<
		if(check == 2 and poss == 0){
			swap(a, c), swap(b, d), swap(h1, h2);
			ll com;
			MOD2(com = h1 - h[no]);
			
			ll other_ki_hash ;
			MOD2(other_ki_hash = h2 - com);
			// deb2(com, other_ki_hash);
			int other_no = rev[other_ki_hash];
			// deb(other_no);
			if(other_no == 0){
				poss = 0;
				// cout <<"NO\n";
				// continue;
			}
			int ff = other_no^no;
			// deb(ff);
			if(ff != xy){
				poss = 0;
				// cout <<"NO\n";
				// continue;
			}
			// deb(other_no);
			if(hai(other_no, c, d)){
				//so we solved some other variant of problem
				//for current problem,
				// check for renk
				int e1 = 0, e2 = 0;
				// deb2(no, other_no);
				int jno = no, jother = other_no;
				if(no>other_no) jno--, e1 = 1;
				else if(no<other_no) jother--, e2 = 1;
				int r1 = e1+renk(jno, a, b);
				int r2 = e2+renk(jother, c, d);
				// deb2(e1,e2);
				// deb2(r1,r2);
				if(r1==r2){
					poss = 1;
					// cout << "YES\n";
				}
				else{
					poss = 0;
					// cout <<"NO\n";
				}
			}
			else{
				poss = 0;
				// cout <<"NO\n";
			}
		}
		
		cout << (poss?"YES\n":"NO\n");
		//overrr
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	srand(time(NULL));
	int i,n,k,j,t;
	cin >> t;
	while(t--) solve();

	return 0;
} 
