#include<bits/stdc++.h>
using namespace std;
void Search(int *A,int n,int x)
{
int first=0;
int last=0;
auto lb=lower_bound(A,A+n,x);
first=lb-A;
if(first==n)
cout<<-1<<" ";
else
cout<<first<<" ";
auto ub=upper_bound(A,A+n,x);
last=(ub-A)-1;
if(ub==A+n && A[last]!=x)
{
cout<<-1;
}
else
cout<<last;
}
int main()
{
int n,i,x;
cin>>n;
int *A=new int[n];
for(i=0;i<n;i++)
cin>>A[i];
int q;
cin>>q;
while(q>0)
{
cin>>x;
Search(A,n,x);
cout<<endl;
q–;
}
}