#include <bits/stdc++.h>
using namespace std;
const int MAX = 5000;
vector<int> edge[MAX + 5];
int p[MAX + 5], c[MAX + 5], lft[MAX + 5], used[MAX + 5], vis[MAX + 5],
    cp[MAX + 5], ans[MAX + 5];
int n, m, d, mex, dfn;
bool dfs(int x) {
  for (int i = 0; i < edge[x].size(); i++) {
    int j = edge[x][i];
    if (used[j] != dfn) {
      used[j] = dfn;
      if (cp[j] == -1 || dfs(cp[j])) {
        cp[j] = x;
        return true;
      }
    }
  }
  return false;
}
int main() {
  memset(cp, -1, sizeof(cp));
  int i;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (i = 1; i <= n; i++) scanf("%d", &c[i]);
  scanf("%d", &d);
  for (i = 1; i <= d; i++) {
    scanf("%d", &lft[i]);
    vis[lft[i]] = 1;
  }
  for (i = 1; i <= n; i++) {
    if (!vis[i]) edge[p[i]].push_back(c[i]);
  }
  for (i = d, mex = -1, dfn = 1; i >= 1; i--) {
    while (dfs(mex + 1)) {
      mex++;
      dfn++;
    }
    ans[i] = mex + 1;
    dfn++;
    edge[p[lft[i]]].push_back(c[lft[i]]);
  }
  for (i = 1; i <= d; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
