#include <bits/stdc++.h>
using namespace std;
int n, m, p[5010], c[5010], D, k[5010];
int last[5010], A[5010];
vector<int> G[5010];
bool vis[5010];
int book[5010], now;
bool check(int x) {
  for (int i = 0, v; i < G[x].size(); i++) {
    v = G[x][i];
    if (book[v] == now) continue;
    book[v] = now;
    if (!last[v] || check(last[v] - 5010)) {
      last[v] = x + 5010;
      return 1;
    }
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  scanf("%d", &D);
  for (int i = 1; i <= D; i++) scanf("%d", &k[i]), vis[k[i]] = 1;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    G[p[i]].push_back(c[i]);
  }
  for (int i = D, ans = 0; i >= 1; i--) {
    now++;
    while (check(ans)) ans++, now++;
    A[i] = ans;
    G[p[k[i]]].push_back(c[k[i]]);
  }
  for (int i = 1; i <= D; i++) printf("%d\n", A[i]);
  return 0;
}
