#include <bits/stdc++.h>
using namespace std;
long long n, m, start, fin, a, b, c, v1[200000], v2[200000];
vector<pair<long long, long long> > g[20000];
long long dist[200000];
set<pair<long long, long long> >::iterator it;
set<pair<long long, long long> > sett;
long long qv;
pair<long long, long long> tp;
long long tc;
long long d[1200][1200];
long long bst, bp;
long long ans[20000];
long long used[200000];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  cin >> start >> fin;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b >> c;
    g[a].push_back(make_pair(b, c));
    g[b].push_back(make_pair(a, c));
  }
  for (int i = 1; i <= n; i++) cin >> v1[i] >> v2[i];
  for (int st = 1; st <= n; st++) {
    for (int i = 1; i <= n; i++) dist[i] = 1e18;
    dist[st] = 0;
    sett.clear();
    for (int i = 1; i <= n; i++) sett.insert(make_pair(dist[i], i));
    for (int iter = 1; iter <= n; iter++) {
      it = sett.begin();
      tp = (*it);
      sett.erase(it);
      qv = tp.second;
      for (int i = 0; i < g[qv].size(); i++) {
        long long q = g[qv][i].first;
        long long c = g[qv][i].second;
        tc = c + dist[qv];
        if (dist[q] > tc) {
          sett.erase(make_pair(dist[q], q));
          dist[q] = tc;
          sett.insert(make_pair(dist[q], q));
        }
      }
    }
    for (int i = 1; i <= n; i++)
      if (dist[i] > v1[st])
        d[st][i] = 1e18;
      else
        d[st][i] = v2[st];
  }
  for (int i = 1; i <= n; i++) ans[i] = 1e18;
  ans[start] = 0;
  for (int iter = 1; iter <= n; iter++) {
    bst = bp = 1e18 + 1e12;
    for (int i = 1; i <= n; i++) {
      if (used[i] == 0 && ans[i] < bst) {
        bst = ans[i];
        bp = i;
      }
    }
    used[bp] = 1;
    for (int i = 1; i <= n; i++)
      if (d[bp][i] + bst < ans[i]) ans[i] = d[bp][i] + bst;
  }
  if (ans[fin] > 1e17) ans[fin] = -1;
  cout << ans[fin] << endl;
  cin.get();
  cin.get();
  return 0;
}
