// Arup Guha
// 10/20/2026
// Illustration of Bellman Ford's Algorithm (Solution to Shortest Path 3 on Kattis:
// Single source shortest path, negative weights
// https://open.kattis.com/problems/shortestpath3

import java.util.*;
import java.io.*;

public class shortestpath3 {

	final public static int NO_EDGE = 1000000000;
	
	public static void main(String[] args) throws Exception {
	
		FastScanner stdin = new FastScanner(System.in);
		int numV = stdin.nextInt();
		int numE = stdin.nextInt();
		int numQ = stdin.nextInt();
		int sourceV = stdin.nextInt();
		
		// Process queries.
		while (numV != 0) {
		
			// Add edges.
			ArrayList<edge> g = new ArrayList<edge>();
			for (int i=0; i<numE; i++) {
				int u = stdin.nextInt();
				int v = stdin.nextInt();
				int w = stdin.nextInt();
				g.add(new edge(u,v,w));
			}
			
			// Run regular Bellman-Ford's
			int[] dist1 = relax(numV, sourceV, g, numV-1);
			
			// Do more iterations to see if there are reachable negative weight cycles.
			int[] dist2 = relax(numV, sourceV, g, 2*numV-1);
			
			// Get the list of vertices for which the answer should be -Infinity.
			boolean[] negInfinity = getNegInfinity(g, dist1, dist2);
			
			// Process queries.
			for (int i=0; i<numQ; i++) {
				int v = stdin.nextInt();
				
				// Get these out of the way.
				if (negInfinity[v])
					System.out.println("-Infinity");
				
				// Then these.
				else if (dist1[v] == NO_EDGE)
					System.out.println("Impossible");
					
				// Here the number is good.
				else
					System.out.println(dist1[v]);
			}
		
			// Get next.
			numV = stdin.nextInt();
			numE = stdin.nextInt();
			numQ = stdin.nextInt();
			sourceV = stdin.nextInt();
		}
	}
	
	// Returns a boolean array such that array[i] = true iff there exists a path from a vertex
	// on a negative weight cycle to i.
	public static boolean[] getNegInfinity(ArrayList<edge> eList, int[] dist1, int[] dist2) {
		
		// Form the graph the regular way!
		ArrayList<Integer>[] g = new ArrayList[dist1.length];
		for (int i=0; i<g.length; i++)
			g[i] = new ArrayList<Integer>();
		for (edge e: eList)
			g[e.u].add(e.v);
		
		// Set up multi-source BFS.
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		boolean[] used = new boolean[dist1.length];
		for (int i=0; i<dist1.length; i++) {
			if (dist2[i] < dist1[i]) {
				q.offer(i);
				used[i] = true;
			}
		}
		
		// Run BFS.
		while (q.size() > 0) {
			int cur = q.poll();
			for (Integer next: g[cur]) {
				if (used[next]) continue;
				used[next] = true;
				q.offer(next);
			}
		}
		
		// Returns everyone who we can get to from these vertices.
		return used;
	}
	
	// Note: This runs numIterations of edge relaxation. Traditional Bellman-Fords is n-1 iterations
	//       of edge relaxation. But itself, that doesn't catch negative weight cycles. But it will
	//       return shortest distances in graphs that don't have negative edge weight cycles.
	public static int[] relax(int numV, int sourceV, ArrayList<edge> eList, int numIter) {
	
		// Set up 1 billion to indicate no edge.
		int[] res = new int[numV];
		Arrays.fill(res, NO_EDGE);
		res[sourceV] = 0;
		
		// Number of iterations.
		for (int i=0; i<numIter; i++)
		
			// One pass of edge relaxation.
			for (edge e: eList)
				
				// This part is important...only relax if there's a way to get there.
				if (res[e.u] != NO_EDGE)
					res[e.v] = Math.min(res[e.v], res[e.u]+e.w);
				
		return res;
	}
}

class edge {

	// Edge is u to v directed weight w.
	public int u;
	public int v;
	public int w;
	
	public edge(int myu, int myv, int myw) {
		u = myu;
		v = myv;
		w = myw;
	}
	
}

/*** Fast Scanner ***/
class FastScanner {
    BufferedReader br;
    StringTokenizer st;
	
    public FastScanner(InputStream i) {
        br = new BufferedReader(new InputStreamReader(i));
        st = new StringTokenizer("");
    }
			
    public String next() throws IOException {
        if(st.hasMoreTokens())
            return st.nextToken();
        else
            st = new StringTokenizer(br.readLine());
        return next();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }
	
    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}