#include <bits/stdc++.h>
using namespace std;
int n, m, d, p[6000], c[6000], k[6000], ans[6000], match[6000], v[6000];
vector<int> g[6000];
void link(int x, int y) { g[x].push_back(y); }
int find(int u) {
  for (auto t : g[u]) {
    if (!v[t]) {
      v[t] = 1;
      if (match[t] < 0 || find(match[t])) {
        match[t] = u;
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  memset(match, -1, sizeof(match));
  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]);
  scanf("%d", &d);
  for (int i = 1; i <= d; i++) {
    scanf("%d", &k[i]);
    v[k[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (v[i] == 0) link(p[i], c[i]);
  }
  int u = 0;
  for (int i = d; i >= 1; i--) {
    while (1) {
      memset(v, 0, sizeof(v));
      if (find(u))
        u++;
      else
        break;
    }
    ans[i] = u;
    link(p[k[i]], c[k[i]]);
  }
  for (int i = 1; i <= d; i++) printf("%d\n", ans[i]);
  return 0;
}
