#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long p[5005];
long long c[5005];
long long k[5005];
long long rem[5005];
long long ans[5005];
long long d;
long long curans = 0;
vector<long long> g[5005];
long long par[10004];
void adds(long long x) { g[p[x]].push_back(5000 + c[x]); }
long long vis[50005];
long long tmstamp;
bool canAdd(long long x) {
  if (g[x].size() == 0) return false;
  for (auto &i : g[x]) {
    if (vis[i] == tmstamp) continue;
    if (par[i] == -1) {
      par[i] = x;
      return true;
    }
    vis[i] = tmstamp;
    long long y = par[i];
    if (canAdd(y)) {
      par[i] = x;
      return true;
    }
  }
  return false;
}
void tries() {
  tmstamp += 1;
  while (canAdd(curans)) {
    curans++;
    tmstamp++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  memset(par, -1, sizeof par);
  for (long long i = 1; i <= n; i++) {
    cin >> p[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> c[i];
  }
  cin >> d;
  for (long long i = 1; i <= d; i++) {
    cin >> k[i];
    rem[k[i]] = 1;
  }
  for (long long i = 1; i <= n; i++) {
    if (rem[i] == 0) adds(i);
  }
  for (long long i = d; i >= 1; i--) {
    tries();
    ans[i] = curans;
    adds(k[i]);
  }
  for (long long i = 1; i <= d; i++) cout << ans[i] << "\n";
  return 0;
}
