![](https://img-blog.csdnimg.cn/direct/60f2da5c28a547909f82a412c55eb119.png)
#include<iostream>
using namespace std;
int n,q;
const int N=1e5+10;
int a[N];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
for(int i=0;i<n;i++)
cin>>a[i];
while(q--)
{
int x;
cin>>x;
int l=0,r=n-1;
while(l<r)
{
int mid=l+r>>1;
if(a[mid]>=x)
r=mid;//在mid及其左边
else
l=mid+1;//在mid右边
}
if(a[l]!=x)
cout<<"-1 -1"<<endl;//如果找不到左边边界结束
else
{
cout<<l<<" ";
int l=0,r=n-1;
while(l<r)
{
int mid=l+r+1>>1;
if(a[mid]<=x)
l=mid;//在mid及其右边
else
r=mid-1;//在mid左边
}
cout<<r<<endl;
}
}
return 0;
}