#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5;
int n, m, d, p[N], c[N];
int cnt[N][N], col[N];
set<int> adj[N];
bitset<N> mark;
bool can(int &x) {
  mark[x] = true;
  for (auto u : adj[x])
    if (!~col[u]) {
      col[u] = x;
      return true;
    }
  for (auto u : adj[x])
    if (!mark[col[u]] && can(col[u])) {
      col[u] = x;
      return true;
    }
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", p + i);
  for (int i = 0; i < n; i++) {
    scanf("%d", c + i);
    if (!cnt[c[i]][p[i]]++) adj[p[i]].insert(c[i]);
  }
  scanf("%d", &d);
  for (int i = 0; i < d; i++) {
    int u;
    scanf("%d", &u), u--;
    if (!--cnt[c[u]][p[u]]) adj[p[u]].erase(c[u]);
    memset(col, -1, sizeof col);
    for (int j = 0; j <= m; j++) {
      mark.reset();
      if (!can(j)) {
        printf("%d\n", j);
        break;
      }
    }
  }
}
