import java.io.*;
import java.util.*;

//Problem "Playlist"
//9th Internet Olympiad, basic level, season 2007-2008
//Problem Author: Sergey Poromov, poromov@rain.ifmo.ru
//Solution Author: Maxim Buzdalov, buzdalov@rain.ifmo.ru

//A subtle bug about last event.

public class music_mb_bug {
    public static void main(String[] args) throws IOException {
	Scanner in = new Scanner(new File("music.in"));
	int n = in.nextInt();
	String[] names = new String[n];
	int[] lengths = new int[n];
	HashMap<String, Integer> map = new HashMap<String, Integer>();
	for (int i = 0; i < n; ++i) {
	    names[i] = in.next();
	    lengths[i] = in.nextInt();
	    map.put(names[i], i);
	}
	
	int m = in.nextInt(), k = in.nextInt();
	
	int[] rating = new int[n];
	String[] listens = new String[m];
	for (int i = 0; i < m; ++i) {
	    listens[i] = in.next();
	    rating[map.get(listens[i])]++;
	}
	int[] events = new int[k];
	for (int i = 0; i < k; ++i) {
	    events[i] = in.nextInt();
	}
	Arrays.sort(events);
	
	int curTime = 0;
	for (int i = 0, j = 0; i < k; ++i) {
	    int event = events[i];
	    while (j < m && curTime <= event) {
		curTime += lengths[map.get(listens[j])];
		++j;
	    }
	    rating[map.get(listens[j - 1])] -= 2;
	    curTime = event;
	}
	in.close();
	
	PrintWriter out = new PrintWriter("music.out");
	for (int i = 0; i < n; ++i) {
	    out.print(rating[i]);
	    if (i + 1 == n) {
		out.println();
	    } else {
		out.print(" ");
	    }
	}
	out.close();
    }
}
