// Arup Guha
// 2/29/2024
// Dijkstra's Implementation for COP 3503
// Kattis Problem: Single source shortest path, non-negative weights
// https://open.kattis.com/problems/shortestpath1

import java.util.*;

public class sssp {
	
	final public static int NOPATH = -1;

	public static int n;
	public static ArrayList<edge>[] g;

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();
		int numE = stdin.nextInt();
		int numQ = stdin.nextInt();
		int source = stdin.nextInt();
		
		// Keep processing cases.
		while (n != 0) {
		
			// Create graph.
			g = new ArrayList[n];
			for (int i=0; i<n; i++)
				g[i] = new ArrayList<edge>();
			
			// Read in edges.
			for (int i=0; i<numE; i++) {
				int u = stdin.nextInt();
				int v = stdin.nextInt();
				int w = stdin.nextInt();
				g[u].add(new edge(u,v,w));
			}
			
			// Run it.
			int[] dist = dijkstras(source);
			
			// Answer queries.
			for (int i=0; i<numQ; i++) {
				int v = stdin.nextInt();
				
				// Follow their directions.
				if (dist[v] == NOPATH)
					System.out.println("Impossible");
				else
					System.out.println(dist[v]);
			}
			
			// Get next case.
			n = stdin.nextInt();
			numE = stdin.nextInt();
			numQ = stdin.nextInt();
			source = stdin.nextInt();
		}
	}
	
	// Runs Dijkstra's from vertex s.
	public static int[] dijkstras(int s) {
		
		// Set up distance array.
		int[] dist = new int[n];
		Arrays.fill(dist, NOPATH);
		dist[s] = 0;
		
		// Keep track of set s.
		boolean[] inS = new boolean[n];
		int numS = 0;
		
		// This stores our current estimates.
		PriorityQueue<edge> pq = new PriorityQueue<edge>();
		pq.offer(new edge(s,s,0));
		
		// Run until either we have all shortest distances or the pq is empty.
		while (numS < n && pq.size() > 0) {
			
			// Get next estimate.
			edge cur = pq.poll();
			
			// We already did this one.
			if (inS[cur.v]) continue;
			
			// Add to S.
			inS[cur.v] = true;
			numS++;
			
			// Look at all edges leaving cur.v
			for (edge e: g[cur.v]) {
				if (dist[e.v] == -1 || cur.w + e.w < dist[e.v]) {
					dist[e.v] = cur.w + e.w;
					pq.offer(new edge(s, e.v, dist[e.v]));
				}
			}
		}
		
		// Ta da!
		return dist;
	}
}

// Will use edge class also as my estimate class.
class edge implements Comparable<edge> {

	public int u;
	public int v;
	public int w;
	
	public edge(int myu, int myv, int myw) {
		u = myu;
		v = myv;
		w = myw;
	}
	
	public int compareTo(edge other) {
		return this.w - other.w;
	}
}