#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 31;
vector<pair<long long, long long> > g[1000];
long long d[1000][1000];
int t[1000][2];
int n, m;
void dijkstra(int source) {
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      q;
  q.push(pair<long long, long long>(0, source));
  vector<bool> v(n, false);
  while (!q.empty()) {
    pair<long long, long long> e = q.top();
    q.pop();
    long long i = e.second;
    long long c = e.first;
    if (v[i]) continue;
    d[source][i] = c;
    v[i] = true;
    for (int j = 0; j < (int)g[i].size(); j++)
      q.push(pair<long long, long long>(c + g[i][j].first, g[i][j].second));
  }
}
int main() {
  int x, y, start, end, c;
  cin >> n >> m >> start >> end;
  for (int i = 0; i < 1000; i++)
    for (int j = 0; j < 1000; j++) d[i][j] = inf;
  start--;
  end--;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> c;
    x--;
    y--;
    bool found = false;
    for (int j = 0; j < (int)g[x].size(); j++)
      if (g[x][j].second == y) {
        g[x][j].first = min(g[x][j].first, (long long)c);
        found = true;
        break;
      }
    if (!found) g[x].push_back(pair<long long, long long>(c, y));
    found = false;
    for (int j = 0; j < (int)g[y].size(); j++)
      if (g[y][j].second == x) {
        g[y][j].first = min(g[y][j].first, (long long)c);
        found = true;
        break;
      }
    if (!found) g[y].push_back(pair<long long, long long>(c, x));
  }
  for (int i = 0; i < n; i++) cin >> t[i][0] >> t[i][1];
  for (int i = 0; i < n; i++) dijkstra(i);
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      q;
  q.push(pair<long long, long long>(0, start));
  vector<bool> v(n, false);
  while (!q.empty()) {
    pair<long long, long long> e = q.top();
    q.pop();
    long long i = e.second;
    long long c = e.first;
    if (i == end) {
      cout << c << endl;
      return 0;
    }
    if (v[i]) continue;
    v[i] = true;
    for (int j = 0; j < n; j++)
      if (d[i][j] <= t[i][0])
        q.push(pair<long long, long long>(c + t[i][1], j));
  }
  cout << -1 << endl;
  return 0;
}
