#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  x *= f;
}
template <class T>
void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9)
    write(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
template <class T>
void writeln(T x) {
  write(x), putchar('\n');
}
const long long inf = 1e14;
const int N = 1005;
vector<pair<int, long long> > e[N], E[N];
int n, m, x, y;
long long d[N];
void add_edge() {
  int u, v;
  long long w;
  scanf("%d%d%lld", &u, &v, &w);
  e[u].push_back(make_pair(v, w));
  e[v].push_back(make_pair(u, w));
}
void dijkstra(int S) {
  long long t, c;
  scanf("%lld%lld", &t, &c);
  for (int i = 1; i <= n; ++i) d[i] = inf;
  d[S] = 0;
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      pq;
  pq.push(make_pair(d[S], S));
  while (!pq.empty()) {
    int now = pq.top().second;
    long long D = pq.top().first;
    pq.pop();
    if (d[now] < D) continue;
    for (int i = 0; i < (int)e[now].size(); ++i) {
      int to = e[now][i].first;
      long long cost = e[now][i].second;
      if (D + cost < d[to]) {
        d[to] = D + cost;
        pq.push(make_pair(d[to], to));
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (d[i] <= t && i != S) {
      E[S].push_back(make_pair(i, c));
    }
  }
}
void init() {
  scanf("%d%d%d%d", &n, &m, &x, &y);
  for (int i = 1; i <= m; ++i) {
    add_edge();
  }
  for (int i = 1; i <= n; ++i) {
    dijkstra(i);
  }
}
void solve() {
  for (int i = 1; i <= n; ++i) d[i] = inf;
  d[x] = 0;
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      pq;
  pq.push(make_pair(d[x], x));
  while (!pq.empty()) {
    int now = pq.top().second;
    long long D = pq.top().first;
    pq.pop();
    if (d[now] < D) continue;
    for (int i = 0; i < (int)E[now].size(); ++i) {
      int to = E[now][i].first;
      long long cost = E[now][i].second;
      if (D + cost < d[to]) {
        d[to] = D + cost;
        pq.push(make_pair(d[to], to));
      }
    }
  }
  if (d[y] == inf) d[y] = -1;
  printf("%lld\n", d[y]);
}
int main() {
  init();
  solve();
  return 0;
}
