L, M, N = map(int, input()) ase = set(list(map(int, input().split()))) bse = set(list(map(int, input().split()))) for _ in range(int(input())): print(len(a & b)) bse = map(lambda x: x + 1, bse)