#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int n, m;
int p[maxn];
int c[maxn];
bool removed[maxn];
vector<int> adj[maxn];
int lt[maxn];
int rt[maxn];
bool visited[maxn];
stack<int> st;
bool dfs(int u) {
  if (visited[u]) return false;
  visited[u] = true;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (rt[v] == -1) {
      rt[v] = u;
      lt[u] = v;
      return true;
    }
  }
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (dfs(rt[v])) {
      rt[v] = u;
      lt[u] = v;
      return true;
    }
  }
  return false;
}
int main() {
  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);
  int d;
  scanf("%d", &d);
  for (int i = 0; i < d; i++) {
    int x;
    scanf("%d", &x);
    st.push(x);
    removed[x] = true;
  }
  for (int i = 1; i <= n; i++) {
    if (removed[i] == true) continue;
    adj[p[i]].push_back(c[i]);
  }
  int ans = -1;
  stack<int> st2;
  memset(lt, -1, sizeof lt);
  memset(rt, -1, sizeof rt);
  while (!st.empty()) {
    while (true) {
      memset(visited, false, sizeof visited);
      if (!dfs(ans + 1)) break;
      ans++;
    }
    st2.push(ans + 1);
    int x = st.top();
    st.pop();
    adj[p[x]].push_back(c[x]);
  }
  while (!st2.empty()) {
    printf("%d\n", st2.top());
    st2.pop();
  }
  return 0;
}
