#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int cx[maxn], cy[maxn], vis[maxn];
int t[maxn][maxn];
vector<int> V[maxn];
int p[maxn], q[maxn];
int a[maxn];
int vv[maxn];
int ans[maxn];
int n, m;
int mex;
int maxx;
bool dfs(int u) {
  for (auto v : V[u]) {
    if (!vis[v]) {
      vis[v] = 1;
      if (cy[v] == -1 || dfs(cy[v])) {
        cx[u] = v;
        cy[v] = u;
        return 1;
      }
    }
  }
  return 0;
}
void solve() {
  while (1) {
    if (cx[mex] == -1) {
      memset(vis, false, sizeof(vis));
      if (dfs(mex))
        mex++;
      else
        break;
    } else
      mex++;
  }
}
int main() {
  memset(cx, -1, sizeof(cx));
  memset(cy, -1, sizeof(cy));
  cin >> n >> m;
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &q[i]);
  int d;
  scanf("%d", &d);
  for (int i = 1; i <= d; i++) {
    scanf("%d", &a[i]);
    vv[a[i]] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!vv[i]) {
      t[p[i]][q[i]] = 1;
      V[p[i]].push_back(q[i]);
    }
  }
  solve();
  for (int i = d; i >= 1; i--) {
    ans[i] = mex;
    if (!t[p[a[i]]][q[a[i]]]) {
      t[p[a[i]]][q[a[i]]] = 1;
      V[p[a[i]]].push_back(q[a[i]]);
    }
    solve();
  }
  for (int i = 1; i <= d; i++) cout << ans[i] << endl;
  return 0;
}
