#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;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZ2MgZ2V0Y2hhcl91bmxvY2tlZAoKI2luY2x1ZGUgPGV4dC9wYl9kcy9hc3NvY19jb250YWluZXIuaHBwPgojaW5jbHVkZSA8ZXh0L3BiX2RzL3RyZWVfcG9saWN5LmhwcD4KI2luY2x1ZGUgPGV4dC9wYl9kcy9kZXRhaWwvc3RhbmRhcmRfcG9saWNpZXMuaHBwPgp1c2luZyBuYW1lc3BhY2UgX19nbnVfcGJkczsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBwaWkgcGFpcjxpbnQsIGludD4KI2RlZmluZSBmbyhpLCBuKSBmb3IoaT0wOyBpPG47IGkrKykKdHlwZWRlZiB0cmVlPCBwaWksIG51bGxfdHlwZSwgbGVzczxwaWk+LCByYl90cmVlX3RhZywgdHJlZV9vcmRlcl9zdGF0aXN0aWNzX25vZGVfdXBkYXRlPiBtc2V0OwpzdHJ1Y3Qgb3N7Cgltc2V0IEE7CglpbnQgVDsKCSNkZWZpbmUgb29rIG9yZGVyX29mX2tleQoJI2RlZm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