#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<vector<int>> g;
vector<int> mp;
vector<bool> used;
bool dfs(int v) {
  used[v] = true;
  for (auto &i : g[v]) {
    if (mp[i] == -1) {
      mp[i] = v;
      return true;
    }
  }
  for (auto &i : g[v]) {
    if (used[mp[i]]) continue;
    if (dfs(mp[i])) {
      mp[i] = v;
      return true;
    }
  }
  return false;
}
int main() {
  cin >> n >> m;
  g.resize(m);
  mp.resize(m, -1);
  used.resize(m);
  vector<int> p(n), c(n);
  for (auto &i : p) {
    cin >> i;
  }
  for (auto &i : c) {
    cin >> i;
    --i;
  }
  cin >> q;
  vector<int> deleted(q);
  vector<bool> deleted_flag(n);
  for (int i = 0, a; i < q; ++i) {
    cin >> a;
    --a;
    deleted[i] = a;
    deleted_flag[a] = true;
  }
  for (int i = 0; i < n; ++i) {
    if (p[i] >= m) continue;
    if (!deleted_flag[i]) g[p[i]].push_back(c[i]);
  }
  vector<int> ans(q);
  int mex = 0;
  for (int i = q - 1; i >= 0; --i) {
    while (mex < m) {
      fill(used.begin(), used.end(), false);
      if (dfs(mex)) {
        ++mex;
      } else {
        break;
      }
    }
    ans[i] = mex;
    int v = deleted[i];
    if (p[v] >= m) continue;
    g[p[v]].push_back(c[v]);
  }
  for (auto i : ans) {
    cout << i << endl;
  }
  return 0;
}
