#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int a[N];
vector<pair<int, int>> vec;
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
int last = 1;
vec.clear();
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
if (a[i] != a[last])
vec.push_back(make_pair(last, i - 1)), last = i;
}
if (last != n)
vec.push_back(make_pair(last, n));
int q;
cin >> q;
while (q--)
{
int l, r;
cin >> l >> r;
auto it = upper_bound(vec.begin(), vec.end(), make_pair(l, 0x3f3f3f3f));
if (it == vec.end())
{
if (r == n && a[r] != a[l])
cout << l << ' ' << r << '\n';
else
cout << "-1 -1\n";
continue;
}
int i = (*it).first;
if (i > r)
cout << "-1 -1\n";
else
cout << l << ' ' << i << '\n';
}
}
}