import java.util.Arrays;
import java.io.IOException;
import java.util.HashSet;
import java.lang.StringBuilder;

public class invasion{
    public static void main(String[] args) throws IOException {
        short n, a;
        int m;
        byte k;

        short t1, t2, b;

	int[][] W;
	short[] bases;
	HashSet<Short> safe;
        StringBuilder out = new StringBuilder();
 
        while (true){
		n = (short) readInt();
		m = readInt();
		a = (short) readInt();
		k = (byte) readInt();
                
                if (n==0 && m==0 && a==0 && k==0){
			System.out.print(out);
                        System.out.flush();
                    break;
		}

		W = new int[n][n];
		for (short i = 0; i < n; i++) {
		    Arrays.fill(W[i], Byte.MAX_VALUE / 2 - 1);
		    W[i][i] = 0;
		}
		bases = new short[a];

		for (int i = 0; i < m; i++) {
			t1 = (short) (readInt() - 1);
		        t2 = (short) (readInt() - 1);
		        W[t1][t2] = readInt();
		        W[t2][t1] = W[t1][t2];
		}
		for (short i = 0; i < a; i++) {
			bases[i] = (short) (readInt() - 1);
		}
		System.in.read();
		
		for (short k_ = 0; k_ < n; k_++)
		    for (short i = 0; i < n; i++)
			for (short j = 0; j < n; j++)
				if (W[i][j] > W[i][k_] + W[k_][j]) {
		                	W[i][j] = W[i][k_] + W[k_][j];
					W[j][i] = W[i][j];
				}
		
		safe = new HashSet<Short>();
		for (short i = 0; i < n; i++)
		    safe.add(i);
		for (short base : bases) {
		        for (Short s : (HashSet<Short>) safe.clone()) {
				if (W[base][s] < k) {
		                        safe.remove(s);
		                }
			}
		        out.append(safe.size());
			out.append("\n");
		}
		out.append("\n");
                
	}
    }
    public static int readInt() throws IOException{
        int line = System.in.read();
        int retval = 0;
        while(true) {
            retval *= 10;
            retval += line - 48;
            if (isWhite(line= System.in.read()))
                break;
        }
        return retval;
    }
    public static boolean isWhite(int num){
        return num == 32 || num == 10 || num == 13;
    }
}
