#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 100;
set<pair<long long, long long> > s;
long long dp[maxn][maxn], dis[maxn];
int t[maxn], c[maxn];
vector<pair<int, int> > v[maxn];
vector<pair<int, int> > g[maxn];
int n;
void dijkstra1(int u) {
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < v[u].size(); j++) {
      int w = v[u][j].first;
      if (dis[u] + v[u][j].second < dis[w] || dis[w] == -1) {
        s.erase(make_pair(dis[w], w));
        dis[w] = dis[u] + v[u][j].second;
        s.insert(make_pair(dis[w], w));
      }
    }
    set<pair<long long, long long> >::iterator it =
        s.lower_bound(make_pair(0, 0));
    if (it == s.end()) return;
    u = (*it).second;
    s.erase(it);
  }
}
void dijkstra(int u, int k) {
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < g[u].size(); j++) {
      int w = g[u][j].first;
      if (dp[k][u] + g[u][j].second < dp[k][w]) {
        s.erase(make_pair(dp[k][w], w));
        dp[k][w] = dp[k][u] + g[u][j].second;
        s.insert(make_pair(dp[k][w], w));
      }
    }
    set<pair<long long, long long> >::iterator it = s.begin();
    u = (*it).second;
    s.erase(s.begin());
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int m, home, dest;
  cin >> n >> m >> home >> dest;
  for (int i = 0; i < m; i++) {
    int u, w, x;
    cin >> u >> w >> x;
    g[u].push_back(make_pair(w, x));
    g[w].push_back(make_pair(u, x));
  }
  for (int i = 1; i <= n; i++) cin >> t[i] >> c[i];
  for (int i = 1; i <= n; i++) {
    memset(dp[i], 63, sizeof dp[i]);
    s.clear();
    for (long long j = 1; j <= n; j++)
      if (j != i) s.insert(make_pair(dp[i][j], j));
    dp[i][i] = 0;
    dijkstra(i, i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j == i) continue;
      if (dp[i][j] <= t[i]) {
        v[i].push_back(make_pair(j, c[i]));
      }
    }
  }
  for (int i = 1; i <= n; i++)
    if (i != home) s.insert(make_pair(dis[i], i));
  memset(dis, -1, sizeof dis);
  dis[home] = 0;
  s.clear();
  for (long long i = 1; i <= n; i++)
    if (i != home) s.insert(make_pair(dis[i], i));
  dijkstra1(home);
  cout << dis[dest] << endl;
  return 0;
}
