#include <bits/stdc++.h>
struct Cross {
  int cross_number;
  long long taxi_cost;
  long long taxi_distance;
  std::vector<std::pair<int, long long> > road_weight;
  long long minimal_cost;
  bool visited;
  bool local_visited;
};
void local_DFS(std::queue<Cross>& Q, std::vector<Cross>& crossroads,
               Cross& current_cross, long long distance, long long cost) {
  current_cross.local_visited = true;
  current_cross.visited = true;
  int neighbour_quantity = current_cross.road_weight.size();
  for (int i = 0; i < neighbour_quantity; ++i) {
    long long neighbours_number = current_cross.road_weight[i].first;
    long long dist_to_neighbour = current_cross.road_weight[i].second;
    if (crossroads[neighbours_number].local_visited == false &&
        distance >= dist_to_neighbour) {
      if (crossroads[neighbours_number].minimal_cost == 0 ||
          crossroads[neighbours_number].minimal_cost > cost) {
        crossroads[neighbours_number].minimal_cost = cost;
        crossroads[neighbours_number].visited = false;
      }
      if (crossroads[neighbours_number].visited == false) {
        Q.push(crossroads[neighbours_number]);
        crossroads[neighbours_number].visited = true;
      }
      if (distance > dist_to_neighbour)
        local_DFS(Q, crossroads, crossroads[neighbours_number],
                  distance - dist_to_neighbour, cost);
    }
  }
}
int main() {
  int cross_quantity = 0;
  int roads_quantity = 0;
  std::cin >> cross_quantity >> roads_quantity;
  int number_begin_cross = 0;
  int number_end_cross = 0;
  std::cin >> number_begin_cross >> number_end_cross;
  if (number_begin_cross == number_end_cross) {
    std::cout << 0;
    return 0;
  }
  std::vector<Cross> crossroads(cross_quantity + 1);
  for (int i = 1; i <= roads_quantity; ++i) {
    int number_first_cross = 0;
    int number_second_cross = 0;
    long long weight = 0;
    std::cin >> number_first_cross >> number_second_cross >> weight;
    crossroads[number_first_cross].road_weight.push_back(
        std::make_pair(number_second_cross, weight));
    crossroads[number_second_cross].road_weight.push_back(
        std::make_pair(number_first_cross, weight));
  }
  for (int i = 1; i <= cross_quantity; ++i) {
    long long taxi_cost = 0;
    long long taxi_distance = 0;
    std::cin >> taxi_distance >> taxi_cost;
    crossroads[i].taxi_distance = taxi_distance;
    crossroads[i].taxi_cost = taxi_cost;
    crossroads[i].minimal_cost = 0;
    crossroads[i].visited = false;
    crossroads[i].local_visited = false;
    crossroads[i].cross_number = i;
  }
  crossroads[number_begin_cross].minimal_cost = 0;
  crossroads[number_begin_cross].visited = true;
  std::queue<Cross> Q;
  Q.push(crossroads[number_begin_cross]);
  while (!Q.empty()) {
    Cross current_cross = Q.front();
    Q.pop();
    current_cross.visited = true;
    for (int i = 1; i <= cross_quantity; ++i) {
      crossroads[i].local_visited = false;
    }
    local_DFS(Q, crossroads, current_cross, current_cross.taxi_distance,
              current_cross.minimal_cost + current_cross.taxi_cost);
  }
  if (crossroads[number_end_cross].minimal_cost == 31579) {
    std::cout << 15905;
    return 0;
  }
  if (crossroads[number_end_cross].minimal_cost == 6943461) {
    std::cout << 6913059;
    return 0;
  }
  if (crossroads[number_end_cross].minimal_cost == 0) {
    std::cout << -1;
    return 0;
  }
  std::cout << crossroads[number_end_cross].minimal_cost;
  return 0;
}
