#include <bits/stdc++.h>
using namespace std;
const int maxn = 10007;
int n, m, d, p[maxn], k[maxn], c[maxn], ans[maxn], vis[maxn], match[maxn];
vector<int> adj[maxn];
bool dfs(int u) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (!vis[v]) {
      vis[v] = 1;
      if (match[v] == -1 || dfs(match[v])) {
        match[v] = u;
        return true;
      }
    }
  }
  return false;
}
int main() {
  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[i];
    vis[k[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      adj[p[i]].push_back(c[i] + 5000);
      adj[c[i] + 5000].push_back(p[i]);
    }
  }
  memset(match, -1, sizeof(match));
  memset(vis, 0, sizeof(vis));
  while (dfs(ans[d])) {
    ans[d]++;
    memset(vis, 0, sizeof(vis));
  }
  for (int i = d - 1; i; i--) {
    adj[p[k[i + 1]]].push_back(c[k[i + 1]] + 5000);
    adj[c[k[i + 1]] + 5000].push_back(p[k[i + 1]]);
    ans[i] = ans[i + 1];
    memset(vis, 0, sizeof(vis));
    while (dfs(ans[i])) {
      ans[i]++;
      memset(vis, 0, sizeof(vis));
    }
  }
  for (int i = 1; i <= d; i++) printf("%d\n", ans[i]);
}
