#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const int LogN = 18;
int minT[LogN][N], maxT[LogN][N], Log[N];
int a[N], b[N], cnt[N], ans[200005];
struct query
{
    int id, l, r, b;
} Q[200005];
inline bool operator<(const query &x, const query &y) { return x.b < y.b || (x.b == y.b && x.r < y.r); }
int qmax(int l, int r)
{
    int z = Log[r - l + 1];
    return max(maxT[z][l], maxT[z][r - (1 << z) + 1]);
}
int qmin(int l, int r)
{
    int z = Log[r - l + 1];
    return min(minT[z][l], minT[z][r - (1 << z) + 1]);
}
int main()
{
    Log[0] = -1;
    for (int i = 1; i < N; i++) Log[i] = Log[i >> 1] + 1;
    int T, m, n;
    scanf("%d", &T);
    while (T--)
    {
        memset(cnt, 0, sizeof(cnt));
        scanf("%d%d", &n, &m);
        int S = int(sqrt(n));
        for (int i = 1; i <= n; i++)
        {
            scanf("%d", a + i);
            minT[0][i] = maxT[0][i] = b[i] = a[i];
        }
        for (int j = 1; j < LogN; j++)
            for (int i = 1; i + (1 << j) - 1 <= n; i++)
                minT[j][i] = min(minT[j - 1][i], minT[j - 1][i + (1 << (j - 1))]),
                maxT[j][i] = max(maxT[j - 1][i], maxT[j - 1][i + (1 << (j - 1))]);
        for (int i = 0; i < m; i++)
        {
            query &q = Q[i];
            scanf("%d%d", &q.l, &q.r);
            q.id = i, q.b = Q[i].l / S;
        }
        sort(b + 1, b + n + 1);
        auto ed = unique(b + 1, b + n + 1);
        for (int i = 1; i <= n; i++) a[i] = lower_bound(b + 1, ed, a[i]) - b;
        std::sort(Q, Q + m);
        for (int i = 0, L = 0, R = 0, tot = 0; i < m; i++)
        {
            int l = Q[i].l, r = Q[i].r;
            while (L < l)
                if (!--cnt[a[L++]]) --tot;
            while (L > l)
                if (!cnt[a[--L]]++) ++tot;
            while (R < r)
                if (!cnt[a[++R]]++) ++tot;
            while (R > r)
                if (!--cnt[a[R--]]) --tot;
            //printf("**** %d %d %d %d %d\n", l, r, qmin(l, r), qmax(l, r), tot);
            ans[Q[i].id] = (qmax(l, r) - qmin(l, r) + 1) == tot;
        }
        for (int i = 0; i < m; i++)
            puts(ans[i] ? "YES" : "NO");
    }
    return 0;
}