#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  const int X = 5000;
  vector<multiset<int>> g(m + 1 + X + 1);
  vector<int> p(n + 1);
  for (int i = 1; i <= n; i++) cin >> p[i];
  vector<int> c(n + 1);
  vector<int> in(X + 1, 0);
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    g[c[i]].emplace(m + 1 + p[i]);
    in[p[i]] += 1;
  }
  vector<int> match(int(g.size()), -1);
  vector<int> vis(int(g.size()), 0);
  function<int(int, int)> dfs = [&](int u, int pmex) -> int {
    if (vis[u]) return 0;
    vis[u] = 1;
    for (int v : g[u]) {
      if (v - (m + 1) > pmex) continue;
      if (match[v] == -1 or dfs(match[v], pmex)) {
        match[u] = v;
        match[v] = u;
        return 1;
      }
    }
    return 0;
  };
  auto konig = [&](int pmex) {
    fill(begin(match), end(match), -1);
    while (true) {
      fill(begin(vis), end(vis), 0);
      bool cnt = 0;
      for (int i = 1; i <= m; i++) {
        if (match[i] == -1) cnt |= dfs(i, pmex);
      }
      if (cnt == 0) break;
    }
    int mcbm = 0;
    for (int i = 1; i <= m; i++) mcbm += (match[i] != -1);
    return (mcbm == pmex + 1);
  };
  int d;
  cin >> d;
  vector<int> z(d);
  for (int it = 0; it < d; it++) {
    int k;
    cin >> k;
    g[c[k]].erase(g[c[k]].find(m + 1 + p[k]));
    in[p[k]] -= 1;
    z[it] = k;
  }
  vector<int> ans(d);
  int pmex = (in[0] == 0) ? -1 : 0;
  for (int it = d - 1; it >= 0; it--) {
    while (konig(pmex + 1)) pmex += 1;
    ans[it] = pmex + 1;
    int k = z[it];
    g[c[k]].emplace(m + 1 + p[k]);
    in[p[k]] += 1;
  }
  for (int ans_i : ans) cout << ans_i << '\n';
  return (0);
}
