#include <bits/stdc++.h>
using namespace std;
int p[5005], c[5005];
int day[5005];
bool out[5005], vi[5005];
int last = 0;
int match[5005];
vector<int> DSK[5005];
bool DFS(int u) {
  if (vi[u] == true) return false;
  vi[u] = true;
  for (int i = 0; i < DSK[u].size(); i++) {
    int w = DSK[u][i];
    if (match[w] == -1 || DFS(match[w])) {
      match[w] = u;
      return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) cin >> c[i];
  int d;
  cin >> d;
  for (int i = 1; i <= d; i++) {
    cin >> day[i];
    out[day[i]] = true;
  }
  for (int i = 1; i <= n; i++)
    if (!out[i]) DSK[p[i]].push_back(c[i]);
  fill(match + 1, match + 1 + m, -1);
  for (int i = d; i >= 1; i--) {
    memset(vi, false, sizeof vi);
    while (DFS(last)) {
      last++;
      memset(vi, false, sizeof vi);
    }
    DSK[p[day[i]]].push_back(c[day[i]]);
    day[i] = last;
  }
  for (int i = 1; i <= d; i++) cout << day[i] << '\n';
}
