#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000 + 10;
inline bool id(const char ch) { return ch >= '0' && ch <= '9'; }
inline int read(void) {
  int s = 0;
  char ch = getchar();
  while (!id(ch)) ch = getchar();
  while (id(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return s;
}
struct Edge {
  int to, nxt;
} edge[MAXN * 10];
int n, m, d, ans[MAXN], vis[MAXN], pre[MAXN], tmpp = 1, tot, hd[MAXN], p[MAXN],
                                              c[MAXN], use[MAXN], st[MAXN];
inline void addedge(const int x, const int y) {
  edge[++tot] = Edge{x, hd[y]}, hd[y] = tot;
  edge[++tot] = Edge{y, hd[x]}, hd[x] = tot;
  return;
}
bool dfs(const int u) {
  for (int i = hd[u]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (vis[to]) continue;
    vis[to] = 1;
    if (!pre[to] || dfs(pre[to])) {
      pre[to] = u;
      return 1;
    }
  }
  return 0;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) p[i] = read() + 1;
  for (int i = 1; i <= n; i++) c[i] = read();
  d = read();
  for (int i = 1; i <= d; i++) st[i] = read(), use[st[i]] = 1;
  for (int i = 1; i <= n; i++)
    if (!use[i]) addedge(p[i], 5001 + c[i]);
  for (int i = d; i >= 1; i--) {
    memset(vis, 0, sizeof(vis));
    while (dfs(tmpp)) tmpp++, memset(vis, 0, sizeof(vis));
    ans[i] = tmpp - 1;
    addedge(p[st[i]], 5001 + c[st[i]]);
  }
  for (int i = 1; i <= d; i++) printf("%d\n", ans[i]);
  return 0;
}
