Problem: There is a tree that has n nodes and n-1 edges. There are military bases on t out of the n nodes. We want to disconnect the bases as much as possible by destroying k edges. The tree will be split into k+1 regions when we destroy k edges. Given the purpose to disconnect the bases, we only consider to split in a way that each of these k+1 regions has at least one base. When we destroy an edge, we must pay destroying cost. Find the minimum destroying cost to split the tree.



Input

The input consists of multiple data sets. Each data set has the following format. The first line consists of three integers n, t, and k (1 \leq n \leq 10,000, 1 \leq t \leq n, 0 \leq k \leq t-1). Each of the next n-1 lines consists of three integers representing an edge. The first two integers represent node numbers connected by the edge. A node number is a positive integer less than or equal to n. The last one integer represents destroying cost. Destroying cost is a non-negative integer less than or equal to 10,000. The next t lines contain a distinct list of integers one in each line, and represent the list of nodes with bases. The input ends with a line containing three zeros, which should not be processed.

Output

For each test case, print its case number and the minimum destroying cost to split the tree with the case number.

Example

Input

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


Output

Case 1: 1
Case 2: 3

Solution (in CPP):

Solution:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007 /5;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
const long double epsA=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}


bool solve(int ca){
	int n,t,k,i,j,ans=0;cin>>n>>t>>k;
	if(n==0){return false;}
	cout<<"Case "<<ca<<": ";
	vector<vector<int>>go(n);
	vector<int>gowa(n);//行き先の残り和
	vector<int>zi(n);//残り次数
	vector<tuple<int,int,int>>edges(n-1);
	vector<tuple<int,int,int>>zyo(n-1);
	vector<bool>kie(n-1);
	for(i=0;i<n-1;i++){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		if(a>b){swap(a,b);}
		edges[i]=mt(c,a,b);
		zyo[i]=mt(a,b,c);
		go[a].pub(b);gowa[a]+=b;zi[a]++;
		go[b].pub(a);gowa[b]+=a;zi[b]++;
	}
	SO(edges);
	for(i=0;i<n-1;i++){
		int a,b,c;tie(c,a,b)=edges[i];
		zyo[i]=mt(a,b,i);
	}
	SO(zyo);
	vector<bool>nobe(n,true);//baseの否定
	for(i=0;i<t;i++){
		int a;cin>>a;a--;
		nobe[a]=false;
	}
	stack<int>eraque;
	for(i=0;i<n;i++){
		if(nobe[i]&&zi[i]==1){eraque.push(i);}
	}
	int bas=0;
	while(k--){
		while(eraque.size()){
			int ter=eraque.top();
			
			eraque.pop();
			if(zi[ter]!=1){continue;}
			
			int it=gowa[ter];
			//cerr<<"eter="<<ter<<"it="<<it<<endl;
			zi[ter]--;
			zi[it]--;
			gowa[it]-=ter;
			if(nobe[it]&&zi[it]==1){eraque.push(it);}
			if(ter>it){swap(ter,it);}
			int ban=get<2>(*lower_bound(zyo.begin(),zyo.end(),mt(ter,it,-1)));
			//cerr<<"ban="<<ban<<endl;
			kie[ban]=1;//この辺は消えた!
		}
		while(kie[bas]){bas++;}
		int c,a,b;tie(c,a,b)=edges[bas];
		ans+=c;
		zi[a]--;gowa[a]-=b;
		if(nobe[a]&&zi[a]==1){eraque.push(a);}
		zi[b]--;gowa[b]-=a;
		if(nobe[b]&&zi[b]==1){eraque.push(b);}
		
		bas++;
		
	}
	cout<<ans<<endl;
	return true;
}
/*
4 3 2
1 2 3
2 3 4
3 4 10
1
3
4
*/
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int ca=1;
	while(solve(ca)){ca++;}
	return 0;
}