#include <stdio.h>
int searchII(int *S, int t, int min, int max){
    if (min > max) return 0;
    int i, m;
    m = (min + max) / 2;
    if (S[m] == t || (S[m] > t ? searchII(S, t, min, m - 1) : searchII(S, t, m + 1, max))) return 1;
    if (min > max) return 0;
}

int main(){
    int n, q, S[1000000], T[50000], i, j, c = 0;
    scanf("%d", &n);
    for (i = 0;i < n;i++) scanf("%d", S + i);
    scanf("%d", &q);
    for (i = 0;i < q;i++) scanf("%d", T + i);
    for (i = 0;i < q;i++){
        printf("%d\n", T[i]);
        c += searchII(S, T[i], 0, q);
    }
    printf("%d\n", c);
    return 0;
}