#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
;
int match[maxn], vis[maxn], ans[maxn], p[maxn], c[maxn], k[maxn], d, n, m;
int ma[maxn][maxn], book[maxn], f[maxn], to[maxn], cnt, nex[maxn];
void add(int a, int b) {
  cnt++;
  to[cnt] = b;
  nex[cnt] = f[a];
  f[a] = cnt;
}
bool dfs(int x) {
  if (vis[x]) return false;
  vis[x] = 1;
  for (int i = f[x]; i; i = nex[i]) {
    int v = to[i];
    if (match[v] == -1 || dfs(match[v])) {
      match[v] = x;
      return true;
    }
  }
  return false;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < maxn; i++) match[i] = -1;
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  scanf("%d", &d);
  for (int i = 1; i <= d; i++) {
    scanf("%d", &k[i]);
    book[k[i]] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (book[i] == 0) add(p[i], c[i]);
  for (int i = d; i >= 1; i--) {
    ans[i] = ans[i + 1];
    while (1) {
      memset(vis, 0, sizeof(vis));
      if (dfs(ans[i]))
        ans[i]++;
      else
        break;
    }
    int x = k[i];
    add(p[x], c[x]);
  }
  for (int i = 1; i <= d; i++) printf("%d\n", ans[i]);
  return 0;
}
