#include <bits/stdc++.h>
using namespace std;
vector<long long> p, c, used, rm;
vector<vector<long long> > g;
bool dfs(long long v) {
  if (used[v]) return 0;
  used[v] = 1;
  for (auto i : g[v]) {
    if (rm[i] == -1 || dfs(rm[i])) {
      rm[i] = v;
      return 1;
    }
  }
  return 0;
}
int main() {
  long long n, m;
  cin >> n >> m;
  p.resize(n);
  c.resize(n);
  g.resize(5001);
  rm.resize(m, -1);
  used.resize(n, 0);
  for (long long i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> c[i];
    c[i]--;
  }
  long long k;
  cin >> k;
  vector<long long> queries(k);
  vector<long long> vis(n, 0);
  vector<long long> ans(k);
  for (long long i = 0; i < k; i++) {
    cin >> queries[i];
    queries[i]--;
    vis[queries[i]] = 1;
  }
  for (long long i = 0; i < n; i++) {
    if (!vis[i]) {
      g[p[i]].push_back(c[i]);
    }
  }
  long long mex = 0;
  for (int i = k - 1; i >= 0; i--) {
    while (true) {
      used.assign(n, 0);
      if (!dfs(mex)) {
        break;
      }
      mex++;
    }
    ans[i] = mex;
    g[p[queries[i]]].push_back(c[queries[i]]);
  }
  for (auto i : ans) {
    cout << i << "\n";
  }
  return 0;
}
