#include <bits/stdc++.h>
using namespace std;
const int M = 1005;
const long long inf = 1e18 + 5;
long long dis[M][M], w[M * M];
int f[M * M], t[M * M], n;
vector<int> adj[M];
void Dij(int root) {
  set<pair<long long, int>> s;
  s.insert(make_pair(0, root));
  for (int i = 1; i <= n; i++) dis[root][i] = inf;
  dis[root][root] = 0;
  while (s.size()) {
    int v = s.begin()->second;
    s.erase(s.begin());
    for (int e : adj[v]) {
      int u = v ^ f[e] ^ t[e];
      if (dis[root][u] > dis[root][v] + w[e]) {
        s.erase(make_pair(dis[root][u], u));
        dis[root][u] = dis[root][v] + w[e];
        s.insert(make_pair(dis[root][u], u));
      }
    }
  }
}
int32_t main() {
  int m, st, fi, ptr = 0;
  cin >> n >> m >> st >> fi;
  for (int i = 0; i < m; i++) {
    cin >> f[i] >> t[i] >> w[i];
    adj[f[i]].push_back(i), adj[t[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) Dij(i);
  for (int i = 1; i <= n; i++) adj[i].clear();
  for (int i = 1; i <= n; i++) {
    long long te, c;
    cin >> te >> c;
    for (int j = 1; j <= n; j++)
      if (j != i && dis[i][j] <= te)
        w[ptr] = c, f[ptr] = i, t[ptr] = j, adj[i].push_back(ptr++);
  }
  memset(dis, 0, sizeof dis), Dij(st);
  return cout << (dis[st][fi] < inf ? dis[st][fi] : -1) << endl, 0;
}
