#include <bits/stdc++.h>
using namespace std;
const long long INF = 2 * 1e18;
int d[113][113];
struct edge {
  int v, w;
};
vector<int> pred(1013, -1);
vector<pair<int, int>> taxi(1013);
vector<vector<edge>> gr(1013);
vector<long long> Dijkstra(int s, int n) {
  vector<long long> d(1013, INF);
  d[s] = 0;
  set<pair<int, int>> q;
  q.insert(make_pair(d[s], s));
  while (!q.empty()) {
    int v = q.begin()->second;
    q.erase(q.begin());
    for (int i = 0; i < gr[v].size(); ++i) {
      int to = gr[v][i].v;
      int len = gr[v][i].w;
      if (d[v] + len < d[to]) {
        q.erase(make_pair(d[to], to));
        d[to] = d[v] + len;
        pred[to] = v;
        q.insert(make_pair(d[to], to));
      }
    }
  }
  return d;
}
int main() {
  int n, m;
  cin >> n >> m;
  int x, y;
  cin >> x >> y;
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    edge tmp;
    tmp.v = v;
    tmp.w = w;
    gr[u].push_back(tmp);
    swap(tmp.v, u);
    gr[u].push_back(tmp);
  }
  for (int i = 1; i <= n; ++i) {
    int t, c;
    cin >> t >> c;
    taxi[i] = (make_pair(t, c));
  }
  vector<vector<long long>> fat(1013);
  for (int i = 1; i <= n; ++i) {
    fat[i] = Dijkstra(i, n);
  }
  for (int i = 0; i < gr.size(); ++i) {
    gr[i].clear();
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      int u, v, w;
      if (fat[i][j] != INF && fat[i][j] <= taxi[i].first) {
        edge tmp;
        u = i;
        tmp.v = j;
        tmp.w = taxi[i].second;
        gr[u].push_back(tmp);
      }
    }
  }
  vector<long long> ans = Dijkstra(x, n);
  if (ans[y] == INF) {
    cout << -1;
  } else {
    cout << ans[y];
  }
  return 0;
}
