#include <bits/stdc++.h>
std::istringstream input() {
  std::string line;
  std::getline(std::cin, line);
  return std::istringstream(line);
}
std::vector<int64_t> solve(const std::vector<int64_t>& prices,
                           const std::vector<unsigned>& colors_frnt,
                           const std::vector<unsigned>& colors_back,
                           const std::vector<unsigned>& colors_pref) {
  std::vector<int64_t> result(colors_pref.size(), 0);
  std::array<std::multiset<std::pair<int64_t, unsigned> >, 4> color2prices;
  for (size_t t_shirt = 0; t_shirt < prices.size(); ++t_shirt) {
    auto price = prices[t_shirt];
    auto color_frnt = colors_frnt[t_shirt];
    auto color_back = colors_back[t_shirt];
    color2prices[color_frnt].insert({price, color_back});
    color2prices[color_back].insert({price, color_frnt});
  }
  for (size_t idx = 0; idx < colors_pref.size(); ++idx) {
    auto color = colors_pref[idx];
    if (color2prices[color].empty()) {
      result[idx] = -1;
    } else {
      auto price_and_color = *color2prices[color].begin();
      color2prices[color].erase(color2prices[color].begin());
      auto price_and_other_color = std::make_pair(price_and_color.first, color);
      color2prices[price_and_color.second].erase(price_and_other_color);
      result[idx] = price_and_color.first;
    }
  }
  return result;
}
int main(int argc, char* argv[]) {
  size_t n_tshirt{};
  input() >> n_tshirt;
  auto stream_prices = input();
  std::vector<int64_t> prices{std::istream_iterator<int64_t>{stream_prices},
                              std::istream_iterator<int64_t>{}};
  auto stream_color_front = input();
  std::vector<unsigned> colors_front{
      std::istream_iterator<unsigned>{stream_color_front},
      std::istream_iterator<unsigned>{}};
  auto stream_color_back = input();
  std::vector<unsigned> colors_back{
      std::istream_iterator<unsigned>{stream_color_back},
      std::istream_iterator<unsigned>{}};
  size_t n_buyers{};
  input() >> n_buyers;
  auto stream_prefered_color = input();
  std::vector<unsigned> colors_prefered{
      std::istream_iterator<unsigned>{stream_prefered_color},
      std::istream_iterator<unsigned>{}};
  auto result = solve(prices, colors_front, colors_back, colors_prefered);
  for (auto price : result) {
    std::cout << price << " ";
  }
  std::cout << std::endl;
  return 0;
}
