#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 210

struct Info{
	Info(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to,cost;
};

struct Edge{
	Edge(int arg_to,int arg_capacity,int arg_rev_index){
		to = arg_to;
		capacity = arg_capacity;
		rev_index = arg_rev_index;
	}
	int to,capacity,rev_index;
};

int V,N,M,L,num_Edge;
int source = 0,sink;

vector<Edge> G[NUM];
vector<Info> first_G[NUM];
bool used[NUM];
int min_dist[NUM][NUM];
int flow_dist[NUM];
int cheked_index[NUM];
int P[NUM],K[NUM];


void add_edge(int from,int to,int capacity){
	G[from].push_back(Edge(to,capacity,G[to].size()));
	G[to].push_back(Edge(from,0,G[from].size()-1));
}

void bfs(int source){
	for(int i = 0; i < V; i++)flow_dist[i] = -1;
	queue<int> Q;
	flow_dist[source] = 0;
	Q.push(source);

	while(!Q.empty()){
		int node_id = Q.front();
		Q.pop();
		for(int i = 0; i < G[node_id].size(); i++){
			Edge &e = G[node_id][i];
			if(e.capacity > 0 && flow_dist[e.to] < 0){
				flow_dist[e.to] = flow_dist[node_id]+1;
				Q.push(e.to);
			}
		}
	}
}

int dfs(int node_id,int sink,int flow){
	if(node_id == sink)return flow;

	for(int &i = cheked_index[node_id]; i < G[node_id].size(); i++){
		Edge &e = G[node_id][i];
		if(e.capacity > 0 && flow_dist[node_id] < flow_dist[e.to]){
			int tmp_flow = dfs(e.to,sink,min(flow,e.capacity));
			if(tmp_flow > 0){
				e.capacity -= tmp_flow;
				G[e.to][e.rev_index].capacity += tmp_flow;
				return tmp_flow;
			}
		}
	}
	return 0;
}


int max_flow(int source,int sink){
	int flow = 0,add;
	while(true){
		bfs(source);
		if(flow_dist[sink] < 0)break;
		for(int i = 0; i < V; i++)cheked_index[i] = 0;
		while((add = dfs(source,sink,BIG_NUM)) > 0){
			flow += add;
		}
	}
	return flow;
}


void func(){

	V = 2*N+2;
	sink = 2*N+1;

	for(int i = 0; i <= 2*N+1; i++){
		first_G[i].clear();
		G[i].clear();
	}

	for(int i = 1; i <= N; i++){
		for(int k = 1; k <= N; k++){
			if(i != k){
				min_dist[i][k] = BIG_NUM;
			}else{
				min_dist[i][k] = 0;
			}
		}
	}

	int from,to,cost;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %d",&from,&to,&cost);
		first_G[from].push_back(Info(to,cost));
		first_G[to].push_back(Info(from,cost));
		min_dist[from][to] = cost;
		min_dist[to][from] = cost;
	}

	for(int mid = 1; mid <= N; mid++){
		for(int start = 1; start <= N; start++){
			if(min_dist[start][mid] == BIG_NUM)continue;
			for(int end = 1; end <= N; end++){
				if(min_dist[mid][end] == BIG_NUM)continue;
				min_dist[start][end] = min(min_dist[start][end],min_dist[start][mid]+min_dist[mid][end]);
			}
		}
	}

	for(int i = 1; i <= N; i++)scanf("%d",&P[i]);
	for(int i = 1; i <= N; i++)scanf("%d",&K[i]);

	for(int i = 1; i <= N; i++){
		add_edge(source,i,P[i]);
	}

	for(int i = 1; i <= N; i++){
		add_edge(N+i,sink,K[i]);
	}

	for(int i = 1; i <= N; i++){
		for(int k = 1; k <= N; k++){
			if(min_dist[i][k] < L){
				add_edge(i,N+k,P[i]);
			}
		}
	}

	printf("%d\n",max_flow(source,sink));
}

int main(){

	while(scanf("%d %d %d",&N,&M,&L) != EOF){
		func();
	}

	return 0;
}



Measured memory_bytes: 3524