#include <bits/stdc++.h>
using namespace std;
using namespace std;
struct pq {
  long long cost, node;
  bool operator<(const pq &b) const { return b.cost < cost; }
};
vector<pq> adj[1010], ciadj[1010];
int Color[1010];
vector<long long> Dijkstra(long long source, long long nodes) {
  priority_queue<pq> Q;
  vector<long long> dist;
  pq U, V;
  long long i, u, v, cost;
  memset(Color, 0, sizeof(Color));
  for (i = 0; i <= nodes; i++) {
    dist.push_back(100000000010000ll);
  }
  dist[source] = 0;
  V.node = source;
  V.cost = 0;
  Q.push(V);
  while (!Q.empty()) {
    U = Q.top();
    Q.pop();
    u = U.node;
    if (Color[u] == 0) {
      for (i = 0; i < adj[u].size(); i++) {
        v = adj[u][i].node;
        cost = adj[u][i].cost;
        if (dist[u] + cost < dist[v]) {
          dist[v] = dist[u] + cost;
          V.node = v;
          V.cost = dist[v];
          Q.push(V);
        }
      }
      Color[u] = 1;
    }
  }
  return dist;
}
vector<long long> djkstra2(long long source, long long nodes) {
  priority_queue<pq> Q;
  vector<long long> dist;
  pq U, V;
  long long i, u, v, cost;
  memset(Color, 0, sizeof(Color));
  for (i = 0; i <= nodes; i++) {
    dist.push_back(100000000010000ll);
  }
  dist[source] = 0;
  V.node = source;
  V.cost = 0;
  Q.push(V);
  while (!Q.empty()) {
    U = Q.top();
    Q.pop();
    u = U.node;
    if (Color[u] == 0) {
      for (i = 0; i < ciadj[u].size(); i++) {
        v = ciadj[u][i].node;
        cost = ciadj[u][i].cost;
        if (dist[u] + cost < dist[v]) {
          dist[v] = dist[u] + cost;
          V.node = v;
          V.cost = dist[v];
          Q.push(V);
        }
      }
      Color[u] = 1;
    }
  }
  return dist;
}
bool edged[1010][1010];
int main() {
  long long n, m, st, end, u, v, cost, ti[1010], ci[1010];
  pq V;
  vector<long long> dist;
  while (cin >> n >> m) {
    int i, j;
    cin >> st >> end;
    for (i = 1; i <= m; i++) {
      cin >> u >> v >> cost;
      if (!edged[u][v]) {
        V.cost = cost;
        V.node = v;
        adj[u].push_back(V);
        V.node = u;
        adj[v].push_back(V);
      } else {
        for (j = 0; j <= (int)adj[u].size() - 1; j++)
          if (adj[u][j].node == v) adj[u][j].cost = min(adj[u][j].cost, cost);
        for (j = 0; j <= (int)adj[v].size() - 1; j++)
          if (adj[v][j].node == u) adj[v][j].cost = min(adj[v][j].cost, cost);
      }
      edged[u][v] = true;
    }
    for (i = 1; i <= n; i++) cin >> ti[i] >> ci[i];
    for (i = 1; i <= n; i++) {
      dist = Dijkstra(i, n);
      for (j = 1; j <= n; j++)
        if (i != j && dist[j] <= ti[i]) {
          V.cost = ci[i];
          V.node = j;
          ciadj[i].push_back(V);
        }
    }
    dist = djkstra2(st, n);
    if (dist[end] >= 100000000010000ll)
      printf("-1\n");
    else
      cout << dist[end] << endl;
  }
  return 0;
}
