For a given weighted graph G(V, E) and a source r, find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path).

Constraints

* 1 ≤ |V| ≤ 100000
* 0 ≤ di ≤ 10000
* 0 ≤ |E| ≤ 500000
* There are no parallel edges
* There are no self-loops

Input

An edge-weighted graph G (V, E) and the source r.


|V| |E| r
s0 t0 d0
s1 t1 d1
:
s|E|-1 t|E|-1 d|E|-1


|V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. r is the source of the graph.

si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.

Output

Print the costs of SSSP in the following format.


c0
c1
:
c|V|-1


The output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ... |V|-1 in order. If there is no path from the source to a vertex, print INF.

Examples

Input

4 5 0
0 1 1
0 2 4
1 2 2
2 3 1
1 3 5


Output

0
1
3
4


Input

4 6 1
0 1 1
0 2 4
2 0 1
1 2 2
3 1 1
3 2 5


Output

3
0
2
INF
import java.util.*;
import java.io.*;

public class Main{

	static class P implements Comparable {
		int x, y;
		P(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(Object o) {
			P p = (P)o;
			if (this.x == p.x && this.y == p.y) return 0;
			if (this.x < p.x || (this.x == p.x && this.y < p.y)) return -1;
			return 1;
		}
	}

	public static void main(String[] args)throws IOException {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int R = sc.nextInt();
		ArrayList<ArrayList<Integer>> g = new ArrayList<ArrayList<Integer>>();
		ArrayList<ArrayList<Integer>> w = new ArrayList<ArrayList<Integer>>();
		for (int i = 0; i < V; i++) {
			g.add(new ArrayList<Integer>());
			w.add(new ArrayList<Integer>());
		}
		for (int i = 0; i < E; i++) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			int d = sc.nextInt();
			g.get(s).add(t);
			w.get(s).add(d);
		}

		PriorityQueue<P> que = new PriorityQueue<P>();
		ArrayList<Integer> dist = new ArrayList<Integer>();
		for (int i = 0; i < V; i++) {
			dist.add(1500000007);
		}
		que.add(new P(0, R));

		while(!que.isEmpty()) {
			P p = que.poll();
			int d = p.x;
			int c = p.y;

			if (d > dist.get(c)) continue;
			dist.set(c, d);

			for (int i = 0; i < g.get(c).size(); i++) {
				int n = g.get(c).get(i);
				int ww = w.get(c).get(i);
				que.add(new P(d + ww, n));				
			}
		}

		for (int i = 0; i < V; i++) {
			if (dist.get(i) >= 1500000000) System.out.println("INF");
			else System.out.println(dist.get(i));
		}
	}
}


