Problem:
Problem H: Winter Bells

The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged near windows for children.

The sleigh she is on departs from a big christmas tree on the fringe of the city. Miracle power that the christmas tree spread over the sky like a web and form a paths that the sleigh can go on. Since the paths with thicker miracle power is easier to go, these paths can be expressed as undirected weighted graph.

Derivering the present is very strict about time. When it begins dawning the miracle power rapidly weakens and Santa Clause can not continue derivering any more. Her pride as a Santa Clause never excuses such a thing, so she have to finish derivering before dawning.

The sleigh a reindeer pulls departs from christmas tree (which corresponds to 0th node), and go across the city to the opposite fringe (n-1 th node) along the shortest path. Santa Clause create presents from the miracle power and shoot them from the sleigh the reindeer pulls at his full power. If there are two or more shortest paths, the reindeer selects one of all shortest paths with equal probability and go along it.

By the way, in this city there are p children that wish to see Santa Clause and are looking up the starlit sky from their home. Above the i-th child's home there is a cross point of the miracle power that corresponds to c[i]-th node of the graph. The child can see Santa Clause if (and only if) Santa Clause go through the node.

Please find the probability that each child can see Santa Clause.

Input

Input consists of several datasets.

The first line of each dataset contains three integers n, m, p, which means the number of nodes and edges of the graph, and the number of the children. Each node are numbered 0 to n-1.

Following m lines contains information about edges. Each line has three integers. The first two integers means nodes on two endpoints of the edge. The third one is weight of the edge.

Next p lines represent c[i] respectively.

Input terminates when n = m = p = 0.

Output

For each dataset, output p decimal values in same order as input. Write a blank line after that.

You may output any number of digit and may contain an error less than 1.0e-6.

Constraints

3 ≤ n ≤ 100

There are no parallel edges and a edge whose end points are identical.

0 < weight of the edge < 10000

Sample Input

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

Output for the Sample Input

1.00000000

0.50000000
0.50000000

Solution in C# (judge verdict: Memory Limit Exceeded)

using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			String s="";
			while(String.IsNullOrEmpty(s))s=Console.ReadLine();
			var d=Array.ConvertAll(s.Split(' '),e=>int.Parse(e));
			if(d[0]==0 && d[1]==0 && d[2]==0)break;
			Sol mySol =new Sol(d);
			mySol.Solve();
			Console.WriteLine("");
		}
	}
}

class Sol{
	public void Solve(){
		int INF=(int)1e9;
		
		int[][] WF=new int[N][];
		for(int i=0;i<N;i++){
			WF[i]=new int[N];
			for(int j=0;j<N;j++){
				WF[i][j]=i==j?0:INF;
			}
			for(int j=0;j<E[i].Count;j++){
				WF[i][E[i][j].To]=E[i][j].Cost;
			}
		}
		
		for(int k=0;k<N;k++){
			for(int i=0;i<N;i++){
				for(int j=0;j<N;j++){
					WF[i][j]=Math.Min(WF[i][k]+WF[k][j],WF[i][j]);
				}
			}
		}
		
		int[] Cost0=new int[N];
		long[] Count0=new long[N];
		for(int i=0;i<N;i++){
			Cost0[i]=INF;
			Count0[i]=0;
		}
		Cost0[0]=0;
		Count0[0]=1;
		
		PriorityQueue<State> PQ=new PriorityQueue<State>();
		PQ.Push(new State(0,0,1));
		while(!PQ.IsEmpty){
			State S=PQ.Top;PQ.Pop();
			int n=S.V;
			int c=S.C;
			long cnt=S.Count;
			for(int j=0;j<E[n].Count;j++){
				if(c+E[n][j].Cost<Cost0[E[n][j].To]){
					Cost0[E[n][j].To]=c+E[n][j].Cost;
					Count0[E[n][j].To]=cnt;
					PQ.Push(new State(E[n][j].To, Cost0[E[n][j].To], Count0[E[n][j].To] ) );
				}else if(c+E[n][j].Cost==Cost0[E[n][j].To]){
					Count0[E[n][j].To]+=cnt;
					PQ.Push(new State(E[n][j].To,Cost0[E[n][j].To],Count0[E[n][j].To]));
				}
			}
		}
		
		int[] Cost=new int[N];
		long[] Count=new long[N];
		for(int i=0;i<N;i++){
			Cost[i]=INF;
			Count[i]=0;
		}
		Cost[N-1]=0;
		Count[N-1]=1;
		PQ.Push(new State(N-1,0,1));
		while(!PQ.IsEmpty){
			State S=PQ.Top;PQ.Pop();
			int n=S.V;
			int c=S.C;
			long cnt=S.Count;
			for(int j=0;j<E[n].Count;j++){
				if(c+E[n][j].Cost<Cost[E[n][j].To]){
					Cost[E[n][j].To]=c+E[n][j].Cost;
					Count[E[n][j].To]=cnt;
					PQ.Push(new State(E[n][j].To,Cost[E[n][j].To],Count[E[n][j].To]));
				}else if(c+E[n][j].Cost==Cost[E[n][j].To]){
					Count[E[n][j].To]+=cnt;
					PQ.Push(new State(E[n][j].To,Cost[E[n][j].To],Count[E[n][j].To]));
				}
			}
		}		
		
		for(int q=0;q<Children.Count;q++){
			if(WF[0][q]+WF[q][0]>WF[0][N-1]){
				Console.WriteLine("0.0");
				continue;
			}
			

			double p=(double)Count0[Children[q]]*(double)Count[Children[q]]/(double)Count0[N-1];
			Console.WriteLine("{0:F}",p);
		}
		
		
		
		
	}
	
	int N;
	int M;
	int P;
	List<Edge>[] E;
	List<int> Children;
	public Sol(int[] d_){
		N=d_[0];M=d_[1];P=d_[2];
		E=new List<Edge>[N];
		for(int i=0;i<N;i++){
			E[i]=new List<Edge>();
		}
		
		for(int i=0;i<M;i++){
			var d=ria();
			E[d[0]].Add(new Edge(d[1],d[2]));
			E[d[1]].Add(new Edge(d[0],d[2]));
		}
		
		Children=new List<int>();
		for(int i=0;i<P;i++){
			Children.Add(ri());
		}
	}

	class Edge{
		public int To;
		public int Cost;
		public Edge(int t_,int c_){
			To=t_;Cost=c_;
		}
	}
	class State:IComparable<State>{
		public int V;
		public int C;
		public long Count;
		public State(int v_,int c_,long cnt_){
			V=v_;C=c_;Count=cnt_;
		}
		public int CompareTo(State other){
			//逆順
			return this.C>other.C?-1:this.C<other.C?1:0;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}





class PriorityQueue<T> where T:IComparable<T>{

	//T:IComparable
	//IComparerかComparisonを指定してインスタンス化する事も可
	//引数なしインスタンス化⇒ComparedToで比較
	//大きいものほどTopへ

	enum typeCompare{
		isIComparerable=1,
		useIComparer=2,
		useDComparison=3
	}

	List<T> buffer;
	typeCompare tComp;
	IComparer<T> Cmper;
	Comparison<T> Cmp;
	
	public PriorityQueue(IComparer<T> comparer_){
		this.buffer=new List<T>();
		tComp=typeCompare.useIComparer;
		Cmper=comparer_;
		Cmp=null;
	}
	public PriorityQueue(){
		this.buffer=new List<T>();
		tComp=typeCompare.isIComparerable;
	}
	public PriorityQueue(Comparison<T> cmp_){
		this.buffer=new List<T>();
		tComp=typeCompare.useDComparison;
		Cmp=cmp_;
		Cmper=null;
	}
	public PriorityQueue(int capacity,IComparer<T> comparer_){
		this.buffer=new List<T>(capacity);
		tComp=typeCompare.useIComparer;
		Cmper=comparer_;
	}
	public PriorityQueue(int capacity){
		this.buffer=new List<T>(capacity);
		tComp=typeCompare.isIComparerable;
	}
	public PriorityQueue(int capacity,Comparison<T> cmp_){
		this.buffer=new List<T>(capacity);
		tComp=typeCompare.useDComparison;
		Cmp=cmp_;
	}
	

	void PushHeap(List<T> arr,T elem){
		int n=arr.Count;
		buffer.Add(elem);
		
		if(tComp==typeCompare.isIComparerable){
			try{
			while(n!=0){
				int i=(n-1)/2;
				if(arr[n].CompareTo(arr[i]) > 0){
					T tmp=arr[n];arr[n]=arr[i];arr[i]=tmp;
				}
				n=i;
			}
			}
		        catch (Exception e){
				Console.WriteLine("{0} Exception caught.", e);
		        }
		}else if(tComp==typeCompare.useIComparer){
			try{
			while(n!=0){
				int i=(n-1)/2;
				if(Cmper.Compare(arr[n],arr[i]) > 0){
					T tmp=arr[n];arr[n]=arr[i];arr[i]=tmp;
				}
				n=i;
			}
			}
		        catch (Exception e){
				Console.WriteLine("{0} Exception caught.", e);
		        }
		}else if(tComp==typeCompare.useDComparison){
			while(n!=0){
				int i=(n-1)/2;
				if(Cmp(arr[n],arr[i]) > 0){
					T tmp=arr[n];arr[n]=arr[i];arr[i]=tmp;
				}
				n=i;
			}
		}
	}
	
	void PopHeap(List<T> arr){
		int n=arr.Count - 1;
		arr[0] = arr[n];
		arr.RemoveAt(n);
		
		if(tComp==typeCompare.isIComparerable){
			for (int i=0,j;(j = 2*i +1)<n;){
				if((j!=n - 1)&&(arr[j].CompareTo(arr[j+1])<0))j++;
				if (arr[i].CompareTo(arr[j])<0){
					T tmp = arr[j]; arr[j] = arr[i]; arr[i] = tmp;
				}
				i=j;
			}
      		}else if(tComp==typeCompare.useIComparer){
			for (int i=0,j;(j = 2*i +1)<n;){
				if((j!=n - 1)&&(Cmper.Compare(arr[j],arr[j+1])<0))j++;
				if (Cmper.Compare(arr[i],arr[j])<0){
					T tmp = arr[j]; arr[j] = arr[i]; arr[i] = tmp;
				}
				i=j;
			}
		}else if(tComp==typeCompare.useDComparison){
			for (int i=0,j;(j = 2*i +1)<n;){
				if((j!=n - 1)&&(Cmp(arr[i],arr[j])<0))j++;
				if (Cmp(arr[i],arr[j])<0){
					T tmp = arr[j]; arr[j] = arr[i]; arr[i] = tmp;
				}
				i=j;
			}
		}
	}
	
	public void Push(T elem){
		PushHeap(this.buffer, elem);
	}
	
	public void Pop(){
		PopHeap(this.buffer);
	}
	
	public bool Contains(T elem){
		return this.buffer.Contains(elem);
	}
	public T Top{
		get{return this.buffer[0];}
	}
	
	public int Count{
		get{return this.buffer.Count;}
	}
	
	public T this[int i]{
		get{return this.buffer[i];}
	}
	
	public bool IsEmpty{
		get{return this.buffer.Count==0;}
	}
}