#include <bits/stdc++.h>
using namespace std;
struct Star {
  int to, e;
} a[5010];
int head[5010];
int p[5010], leave[5010], gr[5010], q[5010];
int v[5010], res[5010];
int ans[5010];
int cnt;
void addedge(int x, int y) {
  a[++cnt].to = head[x];
  head[x] = cnt;
  a[cnt].e = y;
}
bool solve(int x) {
  if (v[x]) return 0;
  v[x] = 1;
  for (int i = head[x]; i != -1; i = a[i].to)
    if (res[a[i].e] == -1 || solve(res[a[i].e])) return res[a[i].e] = x, 1;
  return 0;
}
int main() {
  memset(head, -1, sizeof(head));
  memset(res, -1, sizeof(res));
  int n, m, x;
  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", gr + i);
  int d;
  scanf("%d", &d);
  for (int i = 1; i <= d; i++) scanf("%d", &q[i]), leave[q[i]] = 1;
  for (int i = 1; i <= n; i++)
    if (!leave[i]) addedge(p[i], gr[i]);
  int mx = 0;
  while (1) {
    memset(v, 0, sizeof(v));
    if (!solve(mx)) break;
    mx++;
  }
  ans[d] = mx;
  for (int i = d; i > 1; i--) {
    addedge(p[q[i]], gr[q[i]]);
    while (1) {
      memset(v, 0, sizeof(v));
      if (!solve(mx)) break;
      mx++;
    }
    ans[i - 1] = mx;
  }
  for (int i = 1; i <= d; i++) printf("%d\n", ans[i]);
  return 0;
}
