#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to;
  int cost;
};
vector<edge> V[1010];
int a[1010], b[1010];
int n, m;
long long dis[1010][1010];
long long cost[1010];
void dijkstra(int s) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      que;
  dis[s][s] = 0;
  que.push(pair<long long, int>(dis[s][s], s));
  while (!que.empty()) {
    pair<long long, int> p = que.top();
    que.pop();
    int v = p.second;
    if (dis[s][v] < p.first) continue;
    for (int i = 0; i < V[v].size(); i++) {
      edge e = V[v][i];
      if (dis[s][e.to] > dis[s][v] + e.cost) {
        dis[s][e.to] = dis[s][v] + e.cost;
        que.push(pair<long long, int>(dis[s][e.to], e.to));
      }
    }
  }
}
void pay(int s) {
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      que;
  fill(cost, cost + 1010, 0x3f3f3f3f3f3f3f3f);
  cost[s] = 0;
  que.push(pair<long long, int>(cost[s], s));
  while (!que.empty()) {
    pair<long long, int> p = que.top();
    que.pop();
    int v = p.second;
    if (cost[v] < p.first) continue;
    for (int i = 1; i <= n; i++) {
      if (dis[v][i] <= a[v] && cost[i] > cost[v] + b[v]) {
        cost[i] = cost[v] + b[v];
        que.push(pair<long long, int>(cost[i], i));
      }
    }
  }
}
int main() {
  int s, e;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &s, &e);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    edge e;
    e.to = v;
    e.cost = w;
    V[u].push_back(e);
    e.to = u;
    V[v].push_back(e);
  }
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 0; i < 1010; i++)
    for (int j = 0; j < 1010; j++) dis[i][j] = 0x3f3f3f3f3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    dijkstra(i);
  }
  pay(s);
  long long ans = cost[e];
  if (ans == 0x3f3f3f3f3f3f3f3f)
    printf("-1\n");
  else
    printf("%lld\n", ans);
  return 0;
}
