#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
bool udah[MAXN], visited[MAXN];
int p[MAXN], c[MAXN], match[2 * MAXN], jwb[MAXN], urut[MAXN];
vector<int> adj[MAXN];
bool dfs(int now) {
  if (visited[now]) return false;
  visited[now] = true;
  for (auto nxt : adj[now]) {
    if (match[nxt] == -1 || dfs(match[nxt])) {
      match[nxt] = now;
      return true;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, d, now = 1, k;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) cin >> c[i];
  cin >> d;
  for (int i = 1; i <= d; i++) {
    cin >> k;
    udah[k] = true;
    urut[now] = k;
    now++;
  }
  for (int i = 1; i <= n; i++) {
    if (!udah[i]) {
      urut[now] = i;
      now++;
    }
  }
  now--;
  int ans = 0;
  memset(match, -1, sizeof(match));
  for (int i = n; i >= 1; i--) {
    jwb[i] = ans;
    adj[p[urut[i]]].push_back(c[urut[i]] + 4999);
    memset(visited, 0, sizeof(visited));
    while (dfs(ans)) {
      memset(visited, 0, sizeof(visited));
      ans++;
    }
  }
  for (int i = 1; i <= d; i++) cout << jwb[i] << endl;
  return 0;
}
