#include <bits/stdc++.h>
using namespace std;
struct node {
  long long to;
  long long v;
};
queue<int> q;
long long flag[1005], d[1005], newp[1005][1005], m, n, s, f;
vector<node> p[1005];
void spfa(long long s) {
  while (!q.empty()) q.pop();
  memset(flag, 0, sizeof(flag));
  q.push(s);
  for (long long i = 0; i <= n; i++) d[i] = 0x7fffffffffffffffLL;
  d[s] = 0;
  while (!q.empty()) {
    long long cur = q.front();
    q.pop();
    flag[cur] = 0;
    for (long long i = 0; i < p[cur].size(); i++) {
      node t = p[cur][i];
      if (d[t.to] > d[cur] + t.v) {
        d[t.to] = d[cur] + t.v;
        if (!flag[t.to]) {
          flag[t.to] = 1;
          q.push(t.to);
        }
      }
    }
  }
}
int main() {
  node t;
  long long i, j, a, b;
  while (cin >> n >> m >> s >> f) {
    for (i = 1; i <= m; ++i) {
      cin >> a >> t.to >> t.v;
      p[a].push_back(t);
      swap(a, t.to);
      p[a].push_back(t);
    }
    for (i = 1; i <= n; ++i) {
      spfa(i);
      for (j = 1; j <= n; ++j) newp[i][j] = d[j];
    }
    for (i = 1; i <= n; ++i) p[i].clear();
    for (i = 1; i <= n; ++i) {
      cin >> a >> b;
      for (j = 1; j <= n; ++j) {
        if (j != i) {
          if (newp[i][j] <= a) {
            t.to = j;
            t.v = b;
            p[i].push_back(t);
          }
        }
      }
    }
    spfa(s);
    if (s == f)
      printf("0\n");
    else if (d[f] == 0 || d[f] == 0x7fffffffffffffffLL)
      printf("-1\n");
    else
      printf("%I64d\n", d[f]);
  }
  return 0;
}
