#include <bits/stdc++.h>
using namespace std;
const int n = 1e3 + 50;
int N, M;
int X, Y;
int pay[n];
int limit[n];
long long cost[n][n], best = 1ll << 50;
vector<pair<int, int> > adj[n];
int main() {
  scanf("%d %d %d %d", &N, &M, &X, &Y);
  for (int i = 1; i <= M; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }
  for (int i = 1; i <= N; i++) {
    int t, c;
    scanf("%d %d", &t, &c);
    limit[i] = t;
    pay[i] = c;
  }
  if (X == Y) {
    puts("0");
    return 0;
  }
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      cost[i][j] = (1ll << 50);
    }
  }
  pay[0] = 0;
  limit[0] = -1;
  cost[X][0] = 0;
  priority_queue<pair<pair<long long, long long>, pair<int, int> > > pq;
  pq.push({{0, 0}, {0, X}});
  while (!pq.empty()) {
    long long c = -pq.top().first.first;
    long long t = pq.top().first.second;
    int taxi = pq.top().second.first;
    int u = pq.top().second.second;
    pq.pop();
    for (auto V : adj[u]) {
      int v = V.first;
      int w = V.second;
      if (w <= limit[u] && c + pay[u] < cost[v][u]) {
        cost[v][u] = pay[u] + c;
        pq.push({{-(c + pay[u]), w}, {u, v}});
      }
      if (t + w <= limit[taxi] && cost[u][taxi] < cost[v][taxi]) {
        cost[v][taxi] = cost[u][taxi];
        pq.push({{-c, t + w}, {taxi, v}});
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    best = min(best, cost[Y][i]);
  }
  printf("%I64d\n", (best >= 1ll << 50 ? -1 : best));
}
