#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000ll * 1000000000ll;
int Size;
long long range[1001];
pair<long long, long long> taxi[1001];
vector<vector<pair<int, long long> > > GrIn, GrOut;
void shortpath(int From) {
  for (int i = 1; i <= Size; ++i) {
    range[i] = INF;
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      q;
  q.push(make_pair(0, From));
  range[From] = 0;
  while (!q.empty()) {
    pair<long long, int> temp = q.top();
    q.pop();
    if (temp.first > range[temp.second]) continue;
    for (int i = 0; i < GrIn[temp.second].size(); ++i) {
      int to = GrIn[temp.second][i].first;
      if (temp.first + GrIn[temp.second][i].second < range[to]) {
        range[to] = temp.first + GrIn[temp.second][i].second;
        q.push(make_pair(range[to], to));
      }
    }
  }
  for (int i = 1; i <= Size; ++i) {
    if (i == From) continue;
    if (range[i] <= taxi[From].first) {
      GrOut[From].push_back(make_pair(i, taxi[From].second));
    }
  }
}
void solve(int from) {
  for (int i = 1; i <= Size; ++i) {
    range[i] = INF;
  }
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      q;
  q.push(make_pair(0, from));
  while (!q.empty()) {
    pair<long long, int> temp = q.top();
    q.pop();
    if (temp.first >= range[temp.second]) continue;
    range[temp.second] = temp.first;
    for (int i = 0; i < GrOut[temp.second].size(); ++i) {
      int to = GrOut[temp.second][i].first;
      if (temp.first + GrOut[temp.second][i].second < range[to]) {
        q.push(make_pair(temp.first + GrOut[temp.second][i].second, to));
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int m, x, y;
  long long a, b, w;
  cin >> Size >> m >> x >> y;
  GrIn.resize(Size + 1, vector<pair<int, long long> >());
  GrOut.resize(Size + 1, vector<pair<int, long long> >());
  for (int i = 0; i < m; ++i) {
    cin >> a >> b >> w;
    GrIn[a].push_back(make_pair(b, w));
    GrIn[b].push_back(make_pair(a, w));
  }
  for (int i = 1; i <= Size; ++i) {
    cin >> a >> b;
    taxi[i].first = a;
    taxi[i].second = b;
  }
  for (int i = 1; i <= Size; ++i) {
    shortpath(i);
  }
  solve(x);
  if (INF == range[y])
    cout << -1;
  else
    cout << range[y];
  return 0;
}
