#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);
if(ub<A+n)
{
last=(ub-A)-1;
cout<<last<<" ";
}
else
cout<<-1<<" ";
}
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–;
}
}