#include <bits/stdc++.h>
using namespace std;
const int MM = 5013;
vector<int> W[MM];
bool Del[MM];
pair<int, int> Stud[MM];
int M1[MM], M2[MM];
int ans[MM], zap[MM], vis[MM];
bool DFS(int w, int kol) {
  vis[w] = kol;
  for (auto v : W[w]) {
    if (v == M1[w]) continue;
    int u = M2[v];
    if (u != -1 && vis[u] == kol) continue;
    if (u == -1 || DFS(u, kol)) {
      M2[v] = w;
      M1[w] = v;
      return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, q;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> Stud[i].first;
  for (int i = 1; i <= n; i++) cin >> Stud[i].second;
  cin >> q;
  for (int i = 1; i <= q; i++) cin >> zap[i], Del[zap[i]] = true;
  for (int i = 1; i <= n; i++)
    if (!Del[i]) W[Stud[i].first].push_back(Stud[i].second);
  for (int i = 0; i <= n; i++) M1[i] = -1, M2[i] = -1;
  int ind = 0;
  int t = 1;
  for (int i = q; i >= 1; i--) {
    while (DFS(ind, t++)) ind++;
    ans[i] = ind;
    W[Stud[zap[i]].first].push_back(Stud[zap[i]].second);
  }
  for (int i = 1; i <= q; i++) cout << ans[i] << "\n";
  return 0;
}
