#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, m, d, a[N], c[N], k[N], vi[N], b[N], mat[N], ans[N];
vector<int> e[N];
bool match(int x) {
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i];
    if (b[y]) continue;
    b[y] = 1;
    if (!mat[y] || match(mat[y])) return mat[y] = x, 1;
  }
  return 0;
}
signed main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), a[i]++;
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  scanf("%d", &d);
  for (int i = d; i; i--) scanf("%d", &k[i]), vi[k[i]] = 1;
  for (int i = 1; i <= n; i++)
    if (!vi[i]) e[a[i]].push_back(c[i]);
  for (int i = 1, s = 1; i <= d; i++) {
    while (match(s)) s++, fill_n(b + 1, m, 0);
    fill_n(b + 1, m, 0);
    ans[d - i + 1] = s - 1;
    e[a[k[i]]].push_back(c[k[i]]);
  }
  for (int i = 1; i <= d; i++) printf("%d\n", ans[i]);
  return 0;
}
