#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Edge1
{
public:
    int to, cost;
    Edge1(){};
    Edge1(int to0, int cost0){to = to0; cost = cost0;}
};

class Edge2
{
public:
    int to, cap, rev;
    Edge2(){};
    Edge2(int to0, int cap0){to = to0; cap = cap0;}
    Edge2(int to0, int cap0, int rev0){to = to0; cap = cap0; rev = rev0;}
};

void shortestPath(const vector<vector<Edge1> >& edges, int start, vector<int>& dist)
{
    dist.assign(edges.size(), INT_MAX);
    dist[start] = 0;
    priority_queue<pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > > q;
    q.push(make_pair(0, start));

    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            Edge1 e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to]){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }
}

void shortestPath(const vector<vector<Edge1> >& edges, vector<vector<int> >& dist)
{
    dist.resize(edges.size());
    for(unsigned i=0; i<edges.size(); ++i)
        shortestPath(edges, i, dist[i]);
}

int maxFlow(const vector<vector<Edge2> >& edges0, int source, int sink)
{
    static vector<vector<Edge2> > edges;
    static vector<unsigned> index;
    static vector<int> level;
    static int n;

    class Func{
    public:
        static void bfs(int s){
            level.assign(n, -1);
            queue<int> q;
            level[s] = 0;
            q.push(s);
            while(!q.empty()){
                int v = q.front();
                q.pop();
                for(unsigned i=0; i<edges[v].size(); ++i){
                    Edge2& e = edges[v][i];
                    if(e.cap > 0 && level[e.to] < 0){
                        level[e.to] = level[v] + 1;
                        q.push(e.to);
                    }
                }
            }
        }
        static int dfs(int s, int t, int f){
            if(s == t)
                return f;
            for(unsigned& i=index[s]; i<edges[s].size(); ++i){
                Edge2& e = edges[s][i];
                if(e.cap > 0 && level[s] < level[e.to]){
                    int g = dfs(e.to, t, min(f, e.cap));
                    if(g > 0){
                        e.cap -= g;
                        edges[e.to][e.rev].cap += g;
                        return g;
                    }
                }
            }
            return 0;
        }
    };

    n = edges0.size();
    edges.assign(n, vector<Edge2>());
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges0[i].size(); ++j){
            const Edge2& e = edges0[i][j];
            edges[i].push_back(Edge2(e.to, e.cap, edges[e.to].size()));
            edges[e.to].push_back(Edge2(i, 0, edges[i].size()-1));
        }
    }

    int ret = 0;
    for(;;){
        Func::bfs(source);
        if(level[sink] < 0)
            return ret;
        index.assign(n, 0);
        int f;
        while((f = Func::dfs(source, sink, INT_MAX)) > 0)
            ret += f;
    }

    return 0;
}

int main()
{
    for(;;){
        int n, m, l;
        if(!(cin >> n >> m >> l))
            return 0;

        vector<vector<Edge1> > edges1(n);
        for(int i=0; i<m; ++i){
            int a, b, d;
            cin >> a >> b >> d;
            -- a;
            -- b;
            edges1[a].push_back(Edge1(b, d));
            edges1[b].push_back(Edge1(a, d));
        }

        vector<vector<int> > dist;
        shortestPath(edges1, dist);

        vector<vector<Edge2> > edges2(2*n+2);
        for(int i=0; i<n; ++i){
            int p;
            cin >> p;
            edges2[0].push_back(Edge2(i+1, p));
        }
        for(int i=0; i<n; ++i){
            int k;
            cin >> k;
            edges2[i+n+1].push_back(Edge2(2*n+1, k));
        }
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                if(dist[i][j] < l)
                    edges2[i+1].push_back(Edge2(j+n+1, 1000000));
            }
        }

        cout << maxFlow(edges2, 0, 2*n+1) << endl;
    }
}

Measured memory_bytes: 1828