#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 50005;
vector<int> graph[MAX_N];
vector<int> match(MAX_N, -1);
bool visited[MAX_N];
int n, m, d;
vector<int> query;
int p[MAX_N];
int c[MAX_N];
bool kuhn(int left) {
  if (visited[left]) return false;
  visited[left] = true;
  for (auto right : graph[left]) {
    if (match[right] == -1 || kuhn(match[right])) {
      match[right] = left;
      return true;
    }
  }
  return false;
}
void PrintGraph() {
  for (int i = 0; i < 5; i++) {
    cout << i << " -> ";
    for (auto s : graph[i]) {
      cout << " " << s;
    }
    cout << endl;
  }
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  cin >> d;
  for (int i = 0; i < d; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    query.push_back(tmp);
    visited[tmp] = true;
  }
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      graph[p[i]].push_back(c[i]);
    }
  }
  vector<int> ans;
  reverse(query.begin(), query.end());
  int i = 0;
  for (auto q : query) {
    while (true) {
      memset(visited, false, sizeof(visited));
      if (!kuhn(i)) {
        ans.push_back(i);
        break;
      }
      i++;
    }
    graph[p[q]].push_back(c[q]);
  }
  for (int i = d - 1; i >= 0; i--) {
    cout << ans[i] << "\n";
  }
  return 0;
}
