#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
inline long long read() {
  register long long x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
  return f * x;
}
struct Edge {
  long long to, nxt;
} e[N << 1];
long long head[N], cnt;
inline void add(long long u, long long v) {
  e[++cnt].to = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
long long match[N], p[N], c[N], k[N], ans[N];
bool vis[N], viss[N];
bool dfs(long long u) {
  for (register long long i = head[u]; i; i = e[i].nxt) {
    long long v = e[i].to;
    if (vis[c[v]] || viss[v]) continue;
    vis[c[v]] = true;
    if (match[c[v]] == -1 || dfs(match[c[v]])) {
      match[c[v]] = u;
      return true;
    }
  }
  return false;
}
signed main() {
  long long n = read(), m = read();
  for (register long long i = 1; i <= n; i++) {
    p[i] = read();
    add(p[i], i);
  }
  for (register long long i = 1; i <= n; i++) c[i] = read();
  long long d = read();
  for (register long long i = 1; i <= d; i++) {
    k[i] = read();
    viss[k[i]] = true;
  }
  memset(match, -1, sizeof(match));
  for (register long long i = d; i; i--) {
    for (register long long j = ans[i + 1];; j++) {
      memset(vis, false, sizeof(vis));
      if (!dfs(j)) {
        ans[i] = j;
        break;
      }
    }
    viss[k[i]] = false;
  }
  for (register long long i = 1; i <= d; i++) printf("%lld\n", ans[i]);
  return 0;
}
