#include <bits/stdc++.h>
using namespace std;
int n, m, s, e;
long long w[1002], c[1002], d[1002];
vector<pair<int, long long> > v[1002], v1[1002];
void ope(int x) {
  set<pair<long long, int> > q;
  memset(d, -1, sizeof(d));
  d[x] = 0;
  q.insert(make_pair(0, x));
  while (!q.empty()) {
    int k = q.begin()->second;
    long long l = q.begin()->first;
    q.erase(q.begin());
    if (d[k] != l) continue;
    for (int i = 0; i < v[k].size(); i++) {
      if (d[v[k][i].first] == -1 || d[v[k][i].first] > l + v[k][i].second) {
        d[v[k][i].first] = l + v[k][i].second;
        q.insert(make_pair(d[v[k][i].first], v[k][i].first));
      }
    }
  }
}
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= m; i++) {
    int x, y;
    long long z;
    scanf("%d%d%I64d", &x, &y, &z);
    v[x].push_back(make_pair(y, z));
    v[y].push_back(make_pair(x, z));
  }
  for (int i = 1; i <= n; i++) scanf("%I64d%I64d", w + i, c + i);
  for (int i = 1; i <= n; i++) {
    ope(i);
    for (int j = 1; j <= n; j++)
      if (d[j] <= w[i] && d[j] > 0) v1[i].push_back(make_pair(j, c[i]));
  }
  for (int i = 1; i <= n; i++) v[i] = v1[i];
  ope(s);
  printf("%I64d\n", d[e]);
  return 0;
}
