#include <bits/stdc++.h>
using namespace std;
int n, m;
int st, fn;
long long tcost[1010], tdis[1010];
long long walk[1010][1010];
long long dpt[1010];
long long ans[1010];
vector<pair<int, long long> > E[1010];
long long inf;
int main() {
  inf = 1000000000ll;
  inf *= inf;
  scanf("%d%d%d%d", &n, &m, &st, &fn);
  for (int c = 1; c <= m; c++) {
    int x, y;
    long long z;
    scanf("%d%d%I64d", &x, &y, &z);
    E[x].push_back(make_pair(y, z));
    E[y].push_back(make_pair(x, z));
  }
  for (int c = 1; c <= n; c++) scanf("%I64d%I64d", &tdis[c], &tcost[c]);
  for (int c = 1; c <= n; c++) {
    for (int d = 1; d <= n; d++) dpt[d] = inf;
    dpt[c] = 0ll;
    set<pair<long long, int> > S;
    S.insert(make_pair(0ll, c));
    while (!S.empty()) {
      int node = S.begin()->second;
      long long dis = S.begin()->first;
      S.erase(S.begin());
      if (dis > dpt[node]) continue;
      for (vector<pair<int, long long> >::iterator it = E[node].begin();
           it != E[node].end(); it++)
        if (dis + it->second < dpt[it->first]) {
          dpt[it->first] = dis + it->second;
          S.insert(make_pair(dpt[it->first], it->first));
        }
    }
    for (int d = 1; d <= n; d++) walk[c][d] = dpt[d];
  }
  for (int c = 1; c <= n; c++) ans[c] = inf;
  set<pair<long long, int> > S;
  ans[st] = 0ll;
  S.insert(make_pair(0ll, st));
  while (!S.empty()) {
    int node = S.begin()->second;
    long long dis = S.begin()->first;
    S.erase(S.begin());
    if (dis > ans[node]) continue;
    for (int c = 1; c <= n; c++)
      if (tdis[node] >= walk[node][c] and dis + tcost[node] < ans[c]) {
        ans[c] = dis + tcost[node];
        S.insert(make_pair(ans[c], c));
      }
  }
  if (ans[fn] != inf)
    printf("%I64d\n", ans[fn]);
  else
    printf("-1\n");
  return 0;
}
