Problem: There are students and clubs in a college. The clubs are numbered from to . Each student has a potential and is a member of the club with index . Initially, each student is a member of exactly one club. A technical fest starts in the college, and it will run for the next days. There is a coding competition every day in the technical fest.
Every day, in the morning, exactly one student of the college leaves their club. Once a student leaves their club, they will never join any club again. Every day, in the afternoon, the director of the college will select one student from each club (in case some club has no members, nobody is selected from that club) to form a team for this day's coding competition. The strength of a team is the mex of potentials of the students in the team. The director wants to know the maximum possible strength of the team for each of the coming days. Thus, every day the director chooses such team, that the team strength is maximized.
The mex of the multiset is the smallest non-negative integer that is not present in . For example, the mex of the is , the mex of is and the mex of (empty set) is .
Input Format: The first line contains two integers and (), the number of students and the number of clubs in college.
The second line contains integers (), where is the potential of the -th student.
The third line contains integers (), which means that -th student is initially a member of the club with index .
The fourth line contains an integer (), number of days for which the director wants to know the maximum possible strength of the team.
Each of the next lines contains an integer (), which means that -th student lefts their club on the -th day. It is guaranteed, that the -th student has not left their club earlier.
Output Format: For each of the days, print the maximum possible strength of the team on that day.
Note: Consider the first example:
On the first day, student leaves their club. Now, the remaining students are , , and . We can select students , and to get maximum possible strength, which is . Note, that we can't select students , and , as students and belong to the same club. Also, we can't select students , and , since student has left their club.
On the second day, student leaves their club. Now, the remaining students are , and . We can select students , and to get maximum possible strength, which is .
On the third day, the remaining students are and . We can select students and to get maximum possible strength, which is .
On the fourth day, the remaining student is . We can select student to get maximum possible strength, which is .
On the fifth day, no club has students and so the maximum possible strength is .