#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const int maxv = 10005;
int n, m, k, d;
int p[maxn], c[maxn], be[maxn], sol[maxn];
vector<int> graf[maxv];
int par[maxv];
bool volte[maxv];
void ujra(int v) {
  for (int i = 0; i <= v; i++) volte[i] = false;
}
bool lehet(int start) {
  if (par[start] != start) return true;
  volte[start] = true;
  for (int s : graf[start]) {
    if (!volte[s] && par[s] == s) {
      par[s] = start;
      par[start] = s;
      return true;
    }
    if (!volte[s]) {
      volte[s] = true;
      par[par[s]] = par[s];
      if (lehet(par[s])) {
        par[s] = start;
        par[start] = s;
        return true;
      } else {
        par[par[s]] = s;
      }
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    k = max(k, p[i]);
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  cin >> d;
  set<int> masik;
  for (int i = 0; i < d; i++) {
    cin >> be[i];
    be[i]--;
    masik.insert(be[i]);
  }
  for (int i = 0; i < n; i++) {
    if (masik.count(i) == 0) {
      graf[p[i]].push_back(k + c[i]);
      graf[k + c[i]].push_back(p[i]);
    }
  }
  int mu = 0;
  for (int i = 0; i <= k + m; i++) par[i] = i;
  for (int i = d - 1; i >= 0; i--) {
    ujra(k + m);
    while (mu <= k && lehet(mu)) {
      ujra(k + m);
      mu++;
    }
    sol[i] = mu;
    graf[p[be[i]]].push_back(k + c[be[i]]);
    graf[k + c[be[i]]].push_back(p[be[i]]);
  }
  for (int i = 0; i < d; i++) {
    cout << sol[i] << endl;
  }
  return 0;
}
