import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(),q = sc.nextInt();
int[] a = new int[n];
for(int i=0;i<n;i++)
a[i] = sc.nextInt();
while(q-->0)
{
int k = sc.nextInt();
int left = 0,right = n-1;
while(left<right)
{
int mid = left+right>>1;
if(a[mid]>=k)
right = mid;
else
left = mid+1;
}
int mid = left;
if(a[mid]==k)
{
System.out.print(left+" ");
left = 0;
right = n-1;
while(left<right)
{
mid = left+right+1>>1;
if(a[mid]<=k)
left = mid;
else
right = mid-1;
}
System.out.println(left);
}
else
System.out.println("-1 -1");
}
}
}
学到了在循环内部定义的变量,在循环外面是无法使用的,会报错找不到该变量。但是如果在循环外面先定义了变量,在循环内部就不能再定义该变量了,会报错该变量已经被定义了,但是在循环内部可以对该变量进行修改