#include <bits/stdc++.h>
using namespace std;
const int maxn = 5050;
int n, m, d;
int c[maxn], p[maxn], k[maxn];
int mch[maxn];
bool vis[maxn];
set<int> s[maxn];
vector<int> g[maxn];
int mex;
int ans[maxn];
bool dfs(int v) {
  vis[v] = true;
  for (int u : g[v])
    if (mch[u] == -1) {
      mch[u] = v;
      return true;
    } else if (!vis[mch[u]] and dfs(mch[u])) {
      mch[u] = v;
      return true;
    }
  return false;
}
bool ok(int x) {
  memset(vis, false, sizeof vis);
  return dfs(mex);
}
void see() {
  while (ok(mex)) mex++;
}
int32_t main() {
  memset(mch, -1, sizeof mch);
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    c[i]--;
    s[c[i]].insert(i);
  }
  cin >> d;
  for (int i = 0; i < d; i++) {
    cin >> k[i];
    k[i]--;
    s[c[k[i]]].erase(k[i]);
  }
  for (int i = 0; i < m; i++)
    for (int x : s[i]) g[p[x]].push_back(i);
  see();
  for (int i = d; i--;) {
    ans[i] = mex;
    s[c[k[i]]].insert(k[i]);
    g[p[k[i]]].push_back(c[k[i]]);
    see();
  }
  for (int i = 0; i < d; i++) cout << ans[i] << endl;
  return 0;
}
