#include <bits/stdc++.h>
using namespace std;
inline int getidx(const vector<int>& ar, int x) {
  return lower_bound(ar.begin(), ar.end(), x) - ar.begin();
}
inline long long GCD(long long a, long long b) {
  long long n;
  if (a < b) swap(a, b);
  while (b != 0) {
    n = a % b;
    a = b;
    b = n;
  }
  return a;
}
inline long long LCM(long long a, long long b) {
  if (a == 0 || b == 0) return GCD(a, b);
  return a / GCD(a, b) * b;
}
inline long long CEIL(long long n, long long d) {
  return n / d + (long long)(n % d != 0);
}
inline long long ROUND(long long n, long long d) {
  return n / d + (long long)((n % d) * 2 >= d);
}
const long long MOD = 1e9 + 7;
inline long long POW(long long a, long long n) {
  assert(0 <= n);
  long long ret;
  for (ret = 1; n; a = a * a % MOD, n /= 2) {
    if (n % 2) ret = ret * a % MOD;
  }
  return ret;
}
template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  int cnt = 0;
  for (auto vv : v) {
    os << vv;
    if (++cnt < v.size()) os << ",";
  }
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> v) {
  os << "[";
  int cnt = 0;
  for (auto vv : v) {
    os << vv;
    if (++cnt < v.size()) os << ",";
  }
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
  return os << "(" << p.first << "," << p.second << ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H, debug_out(T...);
}
const int MAXN = 5e3 + 1;
int n, m, d, ar[MAXN], br[MAXN];
multiset<int> g[MAXN];
void input() {
  cin >> n >> m;
  for (int(i) = (0); (i) < (int)(n); ++(i)) cin >> ar[i];
  for (int(i) = (0); (i) < (int)(n); ++(i)) cin >> br[i];
  for (int(i) = (0); (i) < (int)(n); ++(i)) g[ar[i]].insert(br[i] - 1);
  cin >> d;
}
vector<int> ato, bto;
bool vis[MAXN];
bool dfs(int u) {
  if (vis[u]) return false;
  vis[u] = 1;
  for (int v : g[u]) {
    if (bto[v] == -1 || dfs(bto[v])) {
      ato[u] = v, bto[v] = u;
      return true;
    }
  }
  return false;
}
int bimatch() {
  ato.assign(MAXN, -1), bto.assign(m, -1);
  int ret = 0;
  for (int(i) = (0); (i) < (int)(MAXN); ++(i)) {
    memset(vis, 0, sizeof(vis));
    if (dfs(i))
      ++ret;
    else
      return ret;
  }
  return ret;
}
int solve() {
  int cur = bimatch();
  42;
  while (d--) {
    int x;
    cin >> x;
    --x;
    int u = ar[x], v = br[x] - 1;
    g[u].erase(g[u].find(v));
    if (ato[u] != v) {
      cout << cur << '\n';
      continue;
    }
    ato[u] = -1, bto[v] = -1;
    memset(vis, 0, sizeof(vis));
    if (!dfs(u)) {
      do {
        --cur;
        if (ato[cur] != -1) bto[ato[cur]] = -1, ato[cur] = -1;
        memset(vis, 0, sizeof(vis));
      } while (!dfs(u) && cur > u);
    }
    cout << cur << '\n';
  }
  return 0;
}
void execute() { input(), solve(); }
int main(void) {
  cin.tie(0), ios_base::sync_with_stdio(false);
  execute();
  return 0;
}
