#include<bits/stdc++.h>
using namespace std;

int N, M, E, S, T, R;
vector< vector< int > > graph[1 << 8];
const int INF = 1 << 28;
vector< int > C;

// R??¬????????§??????????????¬??°???????????????
void Floyd_Warshall(vector< vector< int > >& graph){
  for(int k = 0; k < graph.size(); k++){
    for(int i = 0; i < graph.size(); i++){
      for(int j = 0; j < graph.size(); j++){
        graph[i][j] = min( graph[i][j], graph[i][k] + graph[k][j]);
      }
    }
  }
  return ;
}
void Add_Floyd_Warshall(vector< vector< int > >& cost, int X, int Y,  int z){
  
  cost[X][Y] = cost[Y][X] = z;
  for(int i = X; i < X + 1; i++) {
    for(int j = 0; j < N; j++) {
      for(int k = 0; k < N; k++) {
        if(cost[j][k] > cost[j][i] + cost[i][k]) {
          cost[j][k] = cost[j][i] + cost[i][k];
        }
      }
    }
  }
      
  for(int i = Y; i < Y + 1; i++) {
    for(int j = 0; j < N; j++) {
      for(int k = 0; k < N; k++) {
        if(cost[j][k] > cost[j][i] + cost[i][k]) {
          cost[j][k] = cost[j][i] + cost[i][k];
        }
      }
    }
  }
}
int solution(vector< int >& number) { // S -> number -> T ???????????§?¨?????????¨??????????????????
  int bit = 0, now = S;
  int cost = 0;
  int cur_cost = 0;

  for(int i = 0; i < number.size(); i++) { // ??????????¨???????
    vector< vector< int > >& g = graph[bit];
    int to = g[now][C[number[i]]];
    if((cur_cost + to > R) || (g[0][C[number[i]]] + 1 < to)) { // ???????????????????????????
      to = g[S][C[number[i]]];
      if(to > R) return(INF);
      cur_cost = to;
      cost     += to + 1;
      now = C[number[i]];
    } else {
      cur_cost += to;
      cost     += to;
      now = C[number[i]];
    }
    bit |= 1 << number[i];
  }

  int to = graph[bit][now][T];

  if((cur_cost + to > R) || (graph[bit][S][T] + 1 < to)) { // ???????????????????????????
    now = S;
    to = graph[bit][now][T];
    if(to > R) return(INF);
    cur_cost = to;
    cost     += to + 1;
  } else {
    cur_cost += to;
    cost     += to;
  }
  return(cost);
}

int done(int idx, vector< int >& number, vector< int >& use, vector< bool >& used) {
  if(idx == use.size()){
    return(solution(number));
  }

  int ret = INF;
  for(int i = 0; i < use.size(); i++) {
    if(used[i]) continue;
    used[i] = true;
    number[idx] = use[i];
    ret = min(ret, done(idx + 1, number, use, used));
    used[i] = false;
  }
  return(ret);
}


int main() {
  cin >> N >> M >> E >> S >> T >> R;
  for(int i = 0; i < 1 << E; i++) graph[i].resize(N, vector< int >(N, INF));
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    graph[0][a][b] = 1;
    graph[0][b][a] = 1;
  }
  for(int i = 0; i < N; i++) {
    graph[0][i][i] = 0;
  }
  Floyd_Warshall(graph[0]);
  for(int i = 0; i < 1 << E; i++) { // O(256*10^4) = O(2.5*10^6)
    for(int j = 0; j < N; j++) {
      for(int k = 0; k < N; k++) graph[i][j][k] = graph[0][j][k];
    }
  }

  vector< int > a(E), b(E); C.resize(E);
  for(int i = 0; i < E; i++) { // O(10^5)
    cin >> a[i] >> b[i] >> C[i];
  }
  

  for(int i = 0; i < 1 << E; i++) { // O(256 * 10^4) = O(2.5 * 10^6)
    for(int j = 0; j < E; j++) if((i >> j) & 1) Add_Floyd_Warshall(graph[i], a[j], b[j], 1);
  }
 
  
  // ????????????????¨?????????????????????????????????????????°???? O(8!) = O(10^4)  ?????????O(8)

  int ret = INF;
  for(int i = 0; i < 1 << E; i++) {
    vector< int > use;
    for(int j = 0; j < E; j++) if((i >> j) & 1) use.push_back(j);
    vector< int > number(use.size());
    vector< bool > used(use.size(), false);
    ret = min(ret, done(0, number, use, used));
  }
  if(ret == INF) cout << -1 << endl;
  else cout << ret << endl;

}

Measured memory_bytes: 11400