import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.StringTokenizer;


public class shelter_dp_bug implements Runnable {
    private static final int MAX_N = 100000;
    private static final int MAX_M = 100000;
    private static final int MAX_DIST = 1000000000;
    
    private BufferedReader in;
    private PrintWriter out;
    StringTokenizer st;

    public void solve() throws IOException {
        int n = nextInt();
        assert 1 <= n && n <= MAX_N;
        Point[] s = new Point[n];
        for (int i = 0; i < n; i++) {
            int dist = nextInt();
            assert 0 < dist && dist <= MAX_DIST;
            s[i] = new Point(i, dist);
        }
        int m = nextInt();
        assert 1 <= m && m <= MAX_M;
        Point[] t = new Point[m];
        for (int i = 0; i < m; i++) {
            int dist = nextInt();
            assert 0 < dist && dist <= MAX_DIST;
            t[i] = new Point(i, dist);
        }
        Arrays.sort(s);
        Arrays.sort(t);
        int currT = 0;
        for (Point p: s) {
            while (currT + 1 < m && Math.abs(t[currT].dist - p.dist) > Math.abs(t[currT + 1].dist - p.dist)) {
                currT++;
            }
            p.answer = t[currT].id;
        }
        Arrays.sort(s, new Comparator<Point>() {
            public int compare(Point p1, Point p2) {
                return p1.id - p2.id;
            }
        });
        for (Point p: s) {
            out.print((p.answer + 1) + " ");
        }
    }
    
    class Point implements Comparable<Point> {
        int id;
        int dist;
        int answer;
        
        public Point(int ii, int dd) {
            id = ii;
            dist = dd;
            answer = -1;
        }

        public int compareTo(Point p) {
            return dist - p.dist;
        }
    }
    
    public String nextToken() throws IOException {
        while (!st.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            st = new StringTokenizer(line);
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public shelter_dp_bug(String file) {
        try {
            in = new BufferedReader(new FileReader(file + ".in"));
            out = new PrintWriter(file + ".out");
            st = new StringTokenizer("");
        } catch (FileNotFoundException e) {
            apstenu(e);
        }
    }

    private void apstenu(IOException e) {
        e.printStackTrace();
        System.exit(1);
    }

    public void run() {
        try {
            solve();
        } catch (IOException e) {
            apstenu(e);
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) {
        new Thread(new shelter_dp_bug("shelter")).start();
    }
}
