#include <bits/stdc++.h>
using namespace std;
const long long oo = 1ll << 17;
const long long mos = 0x7FFFFFFF;
const long long nmos = 0x80000000;
const int inf = 0x3f3f3f3f;
const long long inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9;
const double esp = 1e-8;
const double PI = acos(-1.0);
const double PHI = 0.61803399;
const double tPHI = 0.38196601;
template <typename T>
inline T read(T &x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = f ? -x : x;
}
inline void cmax(int &x, int y) {
  if (x < y) x = y;
}
inline void cmax(long long &x, long long y) {
  if (x < y) x = y;
}
inline void cmin(int &x, int y) {
  if (x > y) x = y;
}
inline void cmin(long long &x, long long y) {
  if (x > y) x = y;
}
const int maxn = 5009;
struct node {
  int club, val;
} a[maxn];
vector<int> mp[maxn];
int vis[maxn];
int dp[maxn][maxn], pt[maxn];
int n, m;
bool dfs(int u) {
  if (vis[u]) return false;
  vis[u] = 1;
  for (int i = 0; i < mp[u].size(); i++) {
    int v = mp[u][i];
    if (dp[v][u] == 0) continue;
    if (pt[v] == -1 || dfs(pt[v])) {
      pt[v] = u;
      return true;
    }
  }
  return false;
}
int ans[maxn], qs[maxn];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].val);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].club);
  for (int i = 1; i <= n; i++) {
    mp[a[i].val].push_back(a[i].club);
    dp[a[i].club][a[i].val]++;
  }
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &qs[i]);
    int id = qs[i];
    dp[a[id].club][a[id].val]--;
  }
  int res = 0;
  memset(pt, -1, sizeof(pt));
  for (int i = q; i >= 1; i--) {
    memset(vis, 0, sizeof(vis));
    while (dfs(res)) {
      memset(vis, 0, sizeof(vis));
      res++;
    }
    int id = qs[i];
    dp[a[id].club][a[id].val]++;
    ans[i] = res;
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
