#include <stdio.h>
int main(){
int n, m;
int t[100000], t2[100000];
scanf("%d", &n);
int n1[n+100];
for(int i = 0;i < n; i++){
scanf("%d", &n1[i]);
t[i] = n1[i];
}
scanf("%d", &m);
int k = n+m;
int m2[m+100];
for(int i = 0, j = n;i < m; i++, j++){
scanf("%d", &m2[i]);
t[j] = m2[i];
}
int max, max_ind;
for(int i = 0; i < k; i++){
max = t[i];
for(int j = 0; j < k; j++){
if(max <= t[j]){
max = t[j];
max_ind = j;
}
}
t2[i] = max;
t[max_ind] = 0;
}
/*for(int i = 0; i < k; i++){
printf("%d ", t2[i]);
}
printf("\n");
*/
for(int i = 0; i < k; i++){
for(int j = 0; j < k; j++){
if (n1[i] == t2[j]){
t2[j] = 1000000;
n1[i] = 9999999;
}
}
}
/*for(int i = 0; i < k; i++){
printf("%d ", t2[i]);
}*/
//printf("\n\n");
for(int i = 0; i < k; i++){
for(int j = 0; j < k; j++){
/*if (n1[i] == t2[j]){
t2[j] = 1000000;
}*/
if (m2[i] == t2[j] ){
t2[j] = 1000000;
m2[i] = 9999999;
printf("%d ", j+1);
}
}
}
return 0;
}