#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535897932384626433832795;
const long long INF = 1LL << 62;
const long long MINF = -1LL << 62;
template <typename T>
T getint() {
  T val = 0;
  char c;
  bool neg = false;
  while ((c = getchar()) && !(c >= '0' && c <= '9')) {
    neg |= c == '-';
  }
  do {
    val = (val * 10) + c - '0';
  } while ((c = getchar()) && (c >= '0' && c <= '9'));
  return val * (neg ? -1 : 1);
}
int n, m;
int nxt = 0;
int matched[5001], st[5001];
vector<int> pots[5001];
vector<int> grps[5001];
int p[5001], c[5001];
bool dfs(int x, vector<vector<int>>& adj) {
  st[x] = 1;
  if (matched[x] == -1) return true;
  for (auto i : adj[x]) {
    if (!st[i] && dfs(i, adj)) {
      matched[i] = matched[x];
      return true;
    }
  }
  st[x] = 2;
  return false;
}
void add_edge(int grp, int pot) {
  pots[grp].push_back(pot);
  grps[pot].push_back(grp);
}
bool match() {
  for (int i = 1; i <= m; ++i) {
    if (matched[i] != -1) continue;
    bool van = false;
    for (auto j : pots[i]) {
      if (nxt == j) van = true;
    }
    if (van) {
      matched[i] = nxt++;
      return true;
    }
  }
  vector<vector<int>> adj(m + 1);
  for (int i = 1; i <= m; ++i) {
    if (matched[i] != -1) {
      for (auto j : grps[matched[i]]) {
        if (i != j) adj[i].push_back(j);
      }
    }
  }
  memset(st, 0, sizeof st);
  for (int i = 1; i <= m; ++i) {
    if (matched[i] == -1) continue;
    bool van = false;
    for (auto j : pots[i]) {
      if (nxt == j) van = true;
    }
    if (van) {
      if (dfs(i, adj)) {
        matched[i] = nxt++;
        return true;
      }
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(matched, -1, sizeof matched);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> p[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
  }
  int d;
  cin >> d;
  vector<int> lst;
  vector<bool> volt(n + 1, false);
  for (int i = 0; i < d; ++i) {
    int akt;
    cin >> akt;
    lst.push_back(akt);
    volt[akt] = true;
  }
  for (int i = 1; i <= n; ++i) {
    if (!volt[i]) add_edge(c[i], p[i]);
  }
  reverse(lst.begin(), lst.end());
  vector<int> ans;
  for (auto i : lst) {
    while (match())
      ;
    ans.push_back(nxt);
    add_edge(c[i], p[i]);
  }
  reverse((ans).begin(), (ans).end());
  for (auto i : ans) cout << i << "\n";
  return 0;
}
