#include <bits/stdc++.h>
using namespace std;
const int maxn = (1e3) + 15;
const int mod = (1e9) + 7;
const long long int inf = (1e12) + 3;
long long int n, m, x, y;
string s;
long long int t[maxn], c[maxn], a[maxn][maxn], b[maxn][maxn];
vector<pair<long long int, int> > edge[maxn], edge2[maxn];
set<pair<long long int, int> > st;
bool mark[maxn];
void di1(int source, int q) {
  mark[q] = 1;
  for (pair<long long int, int> u : edge[q])
    if (!mark[u.first])
      st.insert(pair<long long int, int>(u.second + a[source][q], u.first));
  if (st.size()) {
    pair<long long int, int> z = (*st.begin());
    if (!mark[z.second])
      a[source][z.second] = min(z.first, a[source][z.second]);
    mark[z.second] = 1;
    if (st.size()) st.erase(z), di1(source, z.second);
  }
}
void di2(int source, int q) {
  mark[q] = 1;
  for (pair<long long int, int> u : edge2[q])
    if (!mark[u.first])
      st.insert(pair<long long int, int>(u.second + b[source][q], u.first));
  pair<long long int, int> z = (*st.begin());
  if (!mark[z.second]) b[source][z.second] = min(z.first, b[source][z.second]);
  mark[z.second] = 1;
  if (st.size()) st.erase(z), di2(source, z.second);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  ;
  cin >> n >> m >> x >> y;
  if (x == y) cout << "0" << endl, exit(0);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) a[i][j] = inf, b[i][j] = inf;
    a[i][i] = 0, b[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w, edge[--u].push_back(pair<long long int, int>(--v, w)),
        edge[v].push_back(pair<long long int, int>(u, w));
  }
  if (edge[x - 1].size() <= 0 || edge[y - 1].size() <= 0)
    cout << -1 << endl, exit(0);
  for (int i = 0; i < n; i++) cin >> t[i] >> c[i];
  for (int i = 0; i < n; i++)
    di1(i, i), memset(mark, 0, sizeof mark + 1), st.clear();
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] <= t[i] && i != j)
        edge2[i].push_back(pair<long long int, int>(j, c[i]));
  x--;
  di2(x, x);
  if (b[x][--y] == inf || b[x][y] == 0) cout << -1 << endl, exit(0);
  cout << b[x][y] << endl;
  return 0;
}
