#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n,q;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++)
cin>>a[i];
cin>>q;
for(int i=0;i<q;i++){
int x,y;
cin>>x>>y;
x+=y;
auto it=lower_bound(a.begin(),a.end(),x);
if(it==a.end())cout<<a.size();
else if(*it==x)cout<<-1;
else cout<<it-a.begin();
cout<<'\n';
}
}
return 0;
}
Comments
Post a Comment