#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const double PI = acos(-1);
const double ERR = 1e-10;
int n, m;
int g[maxn][maxn];
vector<int> G[maxn];
int linker[10005];
bool used[10005];
bool dfs(int u) {
  for (auto v : G[u]) {
    if (!used[v]) {
      used[v] = true;
      if (linker[v] == -1 || dfs(linker[v])) {
        linker[v] = u;
        return true;
      }
    }
  }
  return false;
}
int p[maxn], c[maxn], bel[maxn], k[maxn], ans[maxn], book[maxn];
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 d, x;
  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) {
      G[p[i]].push_back(c[i]);
      g[p[i]][c[i]] = 1;
    }
  }
  int pre = 0;
  memset(linker, -1, sizeof(linker));
  for (int i = d; i >= 1; i--) {
    for (int j = pre; j <= 5000; j++) {
      for (int k = 1; k <= m; k++) used[k] = 0;
      if (dfs(j))
        pre++;
      else
        break;
    }
    ans[i] = pre;
    x = k[i];
    if (g[p[x]][c[x]] == 0) {
      G[p[x]].push_back(c[x]);
      g[p[x]][c[x]] = 1;
    }
  }
  for (int i = 1; i <= d; i++) printf("%d\n", ans[i]);
  return 0;
}
