https://www.acwing.com/problem/content/791/
#include <iostream>
#include <cstring>
using namespace std;
const int N = 100010;
int a[N];
int n,q,k;
int main(){
cin>>n>>q;
for(int i=0;i<n;i++)scanf("%d",&a[i]);
for(int i=0;i<q;i++){
scanf("%d",&k);
int l=0,r=n-1;
while(l<r){
int m=l+r>>1;
if(a[m]>=k)r=m;
else l=m+1;
}
if(a[l]!=k)printf("-1 -1\n");
else{
printf("%d ",l);
r=n-1;
while(l<r){
int m=l+r+1>>1;
if(a[m]<=k)l=m;
else r=m-1;
}
printf("%d\n",l);
}
}
return 0;
}