#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
void read(int& val) {
  int x = 0;
  int bz = 1;
  char c;
  for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
    ;
  if (c == '-') {
    bz = -1;
    c = getchar();
  }
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
  val = x * bz;
}
const int maxn = 5e3 + 10;
int n, m, q, qu[maxn], ans[maxn];
int p[maxn], c[maxn];
int match[maxn];
vector<int> g[maxn];
bool vis[maxn];
bool lev[maxn];
bool dfs(int u) {
  if (vis[u]) return 0;
  vis[u] = true;
  for (auto to : g[u]) {
    if (match[to] == -1 || dfs(match[to])) {
      match[to] = u;
      return true;
    }
  }
  return false;
}
void solve() {
  int mex = -1;
  memset(match, -1, sizeof(match));
  for (int i = 1; i <= n; i++)
    if (!lev[i]) g[p[i]].push_back(c[i]);
  for (int i = q; i >= 1; i--) {
    while (true) {
      memset(vis, 0, sizeof(vis));
      if (!dfs(mex + 1)) break;
      mex++;
    }
    ans[i] = mex + 1;
    int pp = qu[i];
    g[p[pp]].push_back(c[pp]);
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++) read(p[i]);
  for (int i = 1; i <= n; i++) read(c[i]);
  read(q);
  for (int i = 1; i <= q; i++) read(qu[i]), lev[qu[i]] = true;
  solve();
  return 0;
}
