import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class shelter_dg {

	public static void main(String[] args) {
		new Thread(){
			public void run() {
				try {
					new shelter_dg().run();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}.start();
	}
	
	class Item implements Comparable<Item> {
		int x, id;
		boolean bomb;

		public Item(int ax, boolean abomb, int aid) {
			x = ax;
			bomb = abomb;
			id = aid;
			assert x > 0 && x <= maxCoordinates : (bomb ? "Shelter " : "Settlement ") + (id + 1) + " has wrong coordinate";
		}

		public int compareTo(Item i) {
			return x - i.x;
		}
	}
	
	final int maxN = 100000;
	final int maxM = 100000;
	final int maxCoordinates = (int) 1e9;

	protected void run() throws IOException {
		BufferedReader in = new BufferedReader(new FileReader("shelter.in"));
		PrintWriter out = new PrintWriter("shelter.out");
		
		int n = Integer.parseInt(in.readLine());
		assert n >= 1 && n <= maxN : "Wrong n";
		StringTokenizer st = new StringTokenizer(in.readLine());
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = Integer.parseInt(st.nextToken());
		}
		int m = Integer.parseInt(in.readLine());
		assert m >= 1 && m <= maxM : "Wrong m";
		Item[] p = new Item[m + n];
		for (int i = 0; i < n; i++) {
			p[i] = new Item(d[i], false, i);
		}
		st = new StringTokenizer(in.readLine());
		for (int i = 0; i < m; i++) {
			p[i + n] = new Item(Integer.parseInt(st.nextToken()), true, i);
		}
		
		Arrays.sort(p);

		/*
		for (int i = 0; i + 1 < n + m; i++) {
			assert p[i].x != p[i + 1].x :
				(p[i].bomb ? "Shelter " : "Settlement ") + (p[i].id + 1) +
				" and " + 
				(p[i + 1].bomb ? "shelter " : "settlement ") + (p[i + 1].id + 1) +
				" have the same coordinate " + p[i].x;
		}
		*/

		Item[] left = new Item[n];
		Item[] right = new Item[n];
		
		Item last = null;
		for (int i = 0; i < n + m; i++) {
			if (p[i].bomb) {
				last = p[i];
			} else {
				left[p[i].id] = last;
			}
		}

		last = null;
		for (int i = n + m - 1; i >= 0; i--) {
			if (p[i].bomb) {
				last = p[i];
			} else {
				right[p[i].id] = last;
			}
		}
		
		for (int i = 0; i < n; i++) {
			assert left[i] != null || right[i] != null : "Bug in program";
			int num = -1;
			if (left[i] == null) {
				num = right[i].id;
			} else {
				num = left[i].id;
				if (right[i] != null && Math.abs(right[i].x - d[i]) < Math.abs(left[i].x - d[i])) {
					num = right[i].id;
				}
			}
			if (i > 0) {
				out.print(" ");
			}
			out.print(num + 1);
		}
		out.println();
		
		assert in.readLine() == null : "Extra information";
		
		in.close();
		out.close();
	}

}
