#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> f;
vector<int> f2;
vector<int> from;
vector<bool> marked;
int sw;
vector<multiset<int>> g;
bool rec(int node, int par) {
  if (marked[node]) return false;
  marked[node] = true;
  from[node] = par;
  if (f2[node] != -1) sw = max(sw, node);
  for (auto nnode : g[node]) {
    if (f[nnode] == -1 || rec(f[nnode], node)) {
      f2[node] = nnode;
      f[nnode] = node;
      return true;
    }
  }
  return false;
}
void fix_path(int x, int prev, int sta) {
  if (x != sta) {
    fix_path(from[x], x, sta);
  }
  f2[x] = prev != -1 ? f2[prev] : -1;
  if (f2[x] != -1) f[f2[x]] = x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  vector<int> p(n);
  vector<int> c(n);
  int ma = 0;
  for (auto& x : p) cin >> x, ma = max(ma, x + 1);
  for (auto& x : c) cin >> x, --x;
  g = vector<multiset<int>>(ma, multiset<int>());
  for (int i = 0; i < n; ++i) {
    g[p[i]].insert(c[i]);
  }
  int res = 0;
  f = vector<int>(m, -1);
  f2 = vector<int>(ma, -1);
  from = vector<int>(ma);
  marked = vector<bool>(ma);
  for (int i = 0; i < ma; ++i) {
    for (int j = 0; j < ma; ++j) marked[j] = false;
    if (!rec(i, -1)) break;
    ++res;
  }
  int d;
  cin >> d;
  for (int i = 0; i < d; ++i) {
    int x;
    cin >> x;
    --x;
    g[p[x]].erase(g[p[x]].find(c[x]));
    if (!g[p[x]].count(c[x])) {
      if (f[c[x]] == p[x]) {
        f2[p[x]] = -1;
        f[c[x]] = -1;
        res = min(res, p[x]);
        while (res < ma) {
          if (f2[res] != -1) {
            ++res;
            continue;
          }
          for (int j = 0; j < ma; ++j) marked[j] = false;
          sw = -1;
          if (rec(res, -1)) {
            ++res;
            continue;
          }
          if (sw > res) {
            fix_path(sw, -1, res);
            ++res;
          } else
            break;
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}
