#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int maxn = 5e3 + 5;
int match[maxn << 2], belone[maxn], po[maxn];
bool vis[maxn << 2], pd[maxn];
vector<int> mp[maxn << 2];
inline bool dfs(int x) {
  for (int i = 0; i < (int)mp[x].size(); ++i) {
    if (!vis[mp[x][i]]) {
      vis[mp[x][i]] = 1;
      if (match[mp[x][i]] == -1 || dfs(match[mp[x][i]])) {
        match[mp[x][i]] = x;
        return 1;
      }
    }
  }
  return 0;
}
int n, m, k, qu[maxn], ans[maxn];
int main() {
  std::ios::sync_with_stdio(0);
  memset(match, -1, sizeof(match));
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> po[i];
  for (int i = 1; i <= n; ++i) cin >> belone[i];
  cin >> k;
  for (int i = 1; i <= k; ++i) cin >> qu[i], pd[qu[i]] = 1;
  for (int i = 1; i <= n; ++i) {
    if (!pd[i]) {
      mp[po[i]].push_back(belone[i] + m);
      mp[belone[i] + m].push_back(po[i]);
    }
  }
  int j = 0;
  for (int i = k; i >= 1; --i) {
    for (; j < m; ++j) {
      memset(vis, 0, sizeof(vis));
      if (!dfs(j)) break;
    }
    ans[i] = j;
    mp[po[qu[i]]].push_back(belone[qu[i]] + m);
    mp[belone[qu[i]] + m].push_back(po[qu[i]]);
  }
  for (int i = 1; i <= k; ++i) cout << ans[i] << endl;
  return 0;
}
