#include <cstdio>
#include <cstring>
#include <climits>
#include <algorithm>

using namespace std;

struct flow_graph{
    int MAX_V,E,s,t,head,tail;
    int *cap,*to,*next,*last,*dist,*q,*now;
    
    flow_graph(){}
    
    flow_graph(int V, int MAX_E){
        MAX_V = V; E = 0;
        cap = new int[2*MAX_E], to = new int[2*MAX_E], next = new int[2*MAX_E];
        last = new int[MAX_V], q = new int[MAX_V];
        dist = new int[MAX_V], now = new int[MAX_V];
        fill(last,last+MAX_V,-1);
    }
    
    void clear(){
        fill(last,last+MAX_V,-1);
        E = 0;
    }
    
    void add_edge(int u, int v, int uv){
        to[E] = v, cap[E] = uv, next[E] = last[u]; last[u] = E++;
        to[E] = u, cap[E] = 0, next[E] = last[v]; last[v] = E++;
    }
  
    bool bfs(){
        fill(dist,dist+MAX_V,-1);
        head = tail = 0;
    
        q[tail] = t; ++tail;
        dist[t] = 0;
    
        while(head<tail){
            int v = q[head]; ++head;
            
            for(int e = last[v];e!=-1;e = next[e]){
                if(cap[e^1]>0 && dist[to[e]]==-1){
                    q[tail] = to[e]; ++tail;
                    dist[to[e]] = dist[v]+1;
                }
            }
        }
        
        return dist[s]!=-1;
    }
  
    int dfs(int v, int f){
        if(v==t) return f;
    
        for(int &e = now[v];e!=-1;e = next[e]){
            if(cap[e]>0 && dist[to[e]]==dist[v]-1){
                int ret = dfs(to[e],min(f,cap[e]));
        
                if(ret>0){
                    cap[e] -= ret;
                    cap[e^1] += ret;
                    return ret;
                }
            }
        }
    
        return 0;
    }
  
    int max_flow(int source, int sink){
        s = source; t = sink;
        int f = 0,df;
    
        while(bfs()){
            for(int i = 0;i<MAX_V;++i) now[i] = last[i];
      
            while(true){
                df = dfs(s,INT_MAX);
                if(df==0) break;
                f += df;
            }
        }
    
        return f;
    }
}G(202,100*100 + 100*2);

int main(){
    int N,M,L;
    int dist[100][100];
    
    while(scanf("%d %d %d",&N,&M,&L) == 3){
        for(int i = 0;i < N;++i){
            dist[i][i] = 0;
            
            for(int j = i + 1;j < N;++j)
                dist[i][j] = dist[j][i] = L;
        }
        
        for(int i = 0,u,v,d;i < M;++i){
            scanf("%d %d %d",&u,&v,&d);
            --u; --v;
            
            dist[u][v] = min(dist[u][v],d);
            dist[v][u] = dist[u][v];
        }
        
        for(int k = 0;k < N;++k)
            for(int i = 0;i < N;++i)
                for(int j = 0;j < N;++j)
                    dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
        
        G.clear();
        
        for(int i = 0,p;i < N;++i){
            scanf("%d",&p);
            G.add_edge(0,1 + i,p);
        }
        
        for(int i = 0,k;i < N;++i){
            scanf("%d",&k);
            G.add_edge(1 + N + i,1 + 2*N,k);
        }
        
        for(int i = 0;i < N;++i)
            for(int j = 0;j < N;++j)
                if(dist[i][j] < L)
                    G.add_edge(1 + i,1 + N + j,1000000);
        
        printf("%d\n",G.max_flow(0,1 + 2*N));
    }
    
    return 0;
}

Measured memory_bytes: 1100