import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class invasion {
	public static void main(String[] args) throws IOException {
		int N,M,A,K,a,a1,a2,a3;
		byte m[][] = new byte[10000][10000];
		boolean mesto[] = new boolean[10000];
		int safe = 0;
		
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			String[] arr = r.readLine().split(" ");
			N = Integer.parseInt(arr[0]);
			M = Integer.parseInt(arr[1]);
			A = Integer.parseInt(arr[2]);
			K = Integer.parseInt(arr[3]);
			safe = N;
			if(N == 0 && M == 0 && A == 0 && K == 0) break;
			
			for(int i=0;i<N;i++){
				for(int j=0;j<N;j++) {
					m[i][j] = (byte) K;
				}
				m[i][i] = 0;
				mesto[i] = false;
			}
			
			for(int i=0; i<M;i++) {
				String[] ar = r.readLine().split(" ");
				a1 = Integer.parseInt(ar[0]) - 1;
				a2 = Integer.parseInt(ar[1]) - 1;
				a3 = Integer.parseInt(ar[2]);
				m[a1][a2] = (byte) a3;
				m[a2][a1] = (byte) a3;
			}
			
			for(int k=0;k<N;k++){
				for(int j=0;j<N;j++) {
					for(int i=0;i<N;i++) {
						if( m[i][k] + m[k][j] < m[i][j] ) {
							m[i][j] = (byte) (m[i][k] + m[k][j]);
						}
					}
				}
			}
			
			/*for(int j=0;j<N;j++) {
				for(int i=0;i<N;i++) {
					System.out.print(""+m[i][j]+" ");
				}
				System.out.println();
			}*/
			
			for(int i = 0; i<A;i++) {
				a = Integer.parseInt(r.readLine()) - 1;
				for(int j = 0;j < N;j++) {
					if(m[j][a] < K && mesto[j] == false) {
						mesto[j] = true;
						safe--;
					}
				}
				System.out.println(""+safe);
			}
			System.out.println();
			r.readLine();
		}
	}
	
	static class MM {
		public int k;
	}
}
