#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, M, D;
  cin >> N >> M;
  vector<int> P(N), C(N);
  for (int i = 0; i < N; ++i) cin >> P[i];
  int limit = *max_element(P.begin(), P.end()) + 1;
  for (int i = 0; i < N; ++i) cin >> C[i], --C[i];
  cin >> D;
  vector<int> R(D);
  for (int i = 0; i < D; ++i) cin >> R[i], --R[i];
  vector<vector<int> > G(M + limit + 1);
  vector<int> match(G.size(), -1);
  int current_matching = 0;
  function<bool(int, vector<bool>&)> find_augment = [&](int pos,
                                                        vector<bool>& vis) {
    vis[pos] = true;
    for (int i : G[pos]) {
      int u = match[i];
      if (u == -1 || (!vis[u] && find_augment(u, vis))) {
        match[pos] = i;
        match[i] = pos;
        return true;
      }
    }
    return false;
  };
  function<void(int)> add_matching = [&](int pos) {
    vector<bool> vis(G.size());
    if (find_augment(pos, vis)) {
      ++current_matching;
    }
  };
  for (int i = 0; i < N; ++i) {
    if (find(R.begin(), R.end(), i) == R.end()) {
      G[C[i]].push_back(P[i] + M);
      G[P[i] + M].push_back(C[i]);
    }
  }
  vector<int> ans(D);
  for (int i = D - 1; i >= 0; --i) {
    while (true) {
      int old_matching = current_matching;
      add_matching(current_matching + M);
      if (old_matching == current_matching) break;
    }
    ans[i] = current_matching;
    G[C[R[i]]].push_back(P[R[i]] + M);
    G[P[R[i]] + M].push_back(C[R[i]]);
  }
  for (int i = 0; i < D; ++i) {
    cout << ans[i] << '\n';
  }
  return 0;
}
