#include <bits/stdc++.h>
using namespace std;
const long long int INF = 2000000000000000000LL;
const double pi = acos(-1.0);
vector<long long int> dist(1005), dad(1005);
vector<vector<pair<long long int, long long int> > > edges(1005);
int used[1005];
vector<long long int> d[1005], a[1005];
vector<long long int> dp(1005);
void Dijkstra(int s) {
  fill(dad.begin(), dad.end(), -1);
  fill(dist.begin(), dist.end(), INF);
  memset(used, 0, sizeof(used));
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int> >,
                 greater<pair<long long int, long long int> > >
      Q;
  Q.push(make_pair(0, s));
  dist[s] = 0;
  while (!Q.empty()) {
    pair<long long int, long long int> p = Q.top();
    Q.pop();
    int here = p.second;
    if (used[here]) continue;
    used[here] = 1;
    for (__typeof((edges[here]).begin()) it = (edges[here]).begin();
         it != (edges[here]).end(); it++) {
      if (dist[here] + it->first < dist[it->second]) {
        dist[it->second] = dist[here] + it->first;
        dad[it->second] = here;
        Q.push(make_pair(dist[it->second], it->second));
      }
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  while (cin >> n >> m) {
    int s, t, u, v, w;
    cin >> s >> t;
    for (int i = 0; i < n + 1; i++) edges[i].clear();
    for (int i = 0; i < m; i++) {
      cin >> u >> v >> w;
      edges[u].push_back(pair<long long int, long long int>(w, v));
      edges[v].push_back(pair<long long int, long long int>(w, u));
    }
    for (int i = 1; i < n + 1; i++) {
      Dijkstra(i);
      d[i] = dist;
    }
    for (int i = 1; i < n + 1; i++) {
      long long int len, cost;
      cin >> len >> cost;
      for (int j = 0; j < n + 1; j++) a[i].push_back(INF);
      a[i][i] = 0;
      for (int j = 1; j < n + 1; j++) {
        if (d[i][j] <= len) {
          a[i][j] = ((a[i][j]) < (cost) ? (a[i][j]) : (cost));
        }
      }
    }
    fill(dp.begin(), dp.end(), INF);
    memset(used, 0, sizeof(used));
    dp[s] = 0;
    for (int i = 0; i < n; i++) {
      long long int mini = INF;
      int v = -1;
      for (int j = 1; j < n + 1; j++) {
        if (!used[j] and dp[j] < mini) {
          mini = dp[j];
          v = j;
        }
      }
      if (v == -1) break;
      used[v] = 1;
      for (int j = 1; j < n + 1; j++) {
        dp[j] = ((dp[j]) < (dp[v] + a[v][j]) ? (dp[j]) : (dp[v] + a[v][j]));
      }
    }
    if (dp[t] >= INF)
      cout << -1 << '\n';
    else
      cout << dp[t] << '\n';
  }
  return 0;
}
