请使用较快的 IO 方式
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
//Scanner sc = new Scanner(System.in);
Read sc=new Read();
int n=sc.nextInt();
int m=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}
for(int i=0;i<m;i++){
int x=sc.nextInt();
int r=n-1;
int l=0;
while(l<r){
int mid=(r+l)/2;
if(a[mid]<x){
l=mid+1;
}
else if(a[mid]>=x){
r=mid;
}
}
if(a[r]==x){
System.out.print((r+1)+" ");
}
else{
System.out.print("-1 ");
}
}
}
}
class Read {
StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public int nextInt() throws Exception {
st.nextToken();
return (int) st.nval;
}
}