#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const int mx = 5e3 + 10;
int n, m;
int p[mx], c[mx], ans[mx], out[mx], d[mx];
bool vis[mx], has[mx];
vector<int> ve[mx];
bool dfs(int u) {
  for (int i = 0; i < ve[u].size(); i++) {
    int v = ve[u][i];
    if (vis[v]) continue;
    vis[v] = 1;
    if (out[v] == -1 || dfs(out[v])) {
      out[v] = u;
      return true;
    }
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
  }
  int t;
  scanf("%d", &t);
  for (int i = 1; i <= t; i++) {
    scanf("%d", &d[i]);
    vis[d[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    ve[p[i]].push_back(c[i]);
  }
  memset(out, -1, sizeof(out));
  ans[t + 1] = 0;
  int id;
  for (int k = t; k >= 1; k--) {
    for (int i = ans[k + 1]; i <= 5000; i++) {
      memset(vis, 0, sizeof(vis));
      if (dfs(i) == false) {
        ans[k] = i;
        break;
      }
    }
    id = d[k];
    ve[p[id]].push_back(c[id]);
  }
  for (int i = 1; i <= t; i++) printf("%d\n", ans[i]);
  return 0;
}
