#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int A[N], B[N];
int club[N][N];
int p[N], c[N];
int vis[N];
set<int> g[N];
int kuhn(int u) {
  if (vis[u]) return 0;
  vis[u] = 1;
  for (int v : g[u]) {
    if (B[v] == -1) {
      A[u] = v;
      B[v] = u;
      return 1;
    }
  }
  for (int v : g[u]) {
    if (kuhn(B[v])) {
      A[u] = v;
      B[v] = u;
      return 1;
    }
  }
  return 0;
}
int l[N];
int main() {
  int n, m;
  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);
    club[c[i]][p[i]]++;
    if (club[c[i]][p[i]] == 1) g[p[i]].insert(c[i]);
  }
  int d;
  scanf("%d", &d);
  for (int i = 0; i < d; i++) {
    scanf("%d", l + i);
    club[c[l[i]]][p[l[i]]]--;
    if (club[c[l[i]]][p[l[i]]] == 0) g[p[l[i]]].erase(c[l[i]]);
  }
  memset(A, -1, sizeof(A));
  memset(B, -1, sizeof(B));
  int mex = 0;
  vector<int> ans;
  for (int i = d - 1; i >= 0; i--) {
    memset(vis, 0, sizeof(vis));
    while (kuhn(mex)) {
      mex++;
      memset(vis, 0, sizeof(vis));
    }
    ans.push_back(mex);
    club[c[l[i]]][p[l[i]]]++;
    if (club[c[l[i]]][p[l[i]]] == 1) g[p[l[i]]].insert(c[l[i]]);
  }
  for (int i = d - 1; i >= 0; i--) printf("%d\n", ans[i], " \n"[i == 0]);
  return 0;
}
