#include <bits/stdc++.h>
const int N = 5005;
using namespace std;
int p[N], c[N], k[N];
int my[N], vis[N];
int ans[N];
int a[N][N], m;
vector<int> g[N];
bool dfs(int x) {
  vis[x] = true;
  for (int i = 0; i < g[x].size(); i++) {
    int u = g[x][i], v = my[u];
    if (v == -1 || !vis[v] && dfs(v)) {
      my[u] = x;
      return true;
    }
  }
  return false;
}
int main() {
  int n, d;
  scanf("%d%d", &n, &m);
  int i, j;
  for (i = 0; i < n; i++) scanf("%d", &p[i]);
  for (i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    c[i]--;
    a[p[i]][c[i]]++;
  }
  scanf("%d", &d);
  for (i = 0; i < d; i++) {
    scanf("%d", &k[i]);
    k[i]--;
    a[p[k[i]]][c[k[i]]]--;
  }
  for (i = 0; i < N; i++)
    for (j = 0; j < m; j++)
      if (a[i][j] > 0) {
        g[i].push_back(j);
      }
  memset(my, -1, sizeof(my));
  int cur;
  for (cur = 0;; cur++) {
    memset(vis, false, sizeof(vis));
    if (!dfs(cur)) break;
  }
  ans[d - 1] = cur;
  for (i = d - 1; i > 0; i--) {
    if (a[p[k[i]]][c[k[i]]] == 0) g[p[k[i]]].push_back(c[k[i]]);
    a[p[k[i]]][c[k[i]]]++;
    memset(vis, false, sizeof(vis));
    while (dfs(cur)) {
      cur++;
      memset(vis, false, sizeof(vis));
    }
    ans[i - 1] = cur;
  }
  for (i = 0; i < d; i++) printf("%d\n", ans[i]);
  return 0;
}
