#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1111;
const long long inf = 1ll << 40;
struct Edge {
  int v, next;
  long long len;
} edge[2000000];
long long Point[MaxN];
int tot;
void insert(int u, int v, long long w) {
  edge[tot].v = v, edge[tot].len = w, edge[tot].next = Point[u];
  Point[u] = tot++;
}
int N, M;
long long dis[MaxN][MaxN], g[MaxN][MaxN];
void clean() {
  tot = 0;
  for (int i = 1; i <= N; i++) Point[i] = -1;
}
bool inQue[MaxN];
void spfa(int s) {
  for (int i = 1; i <= N; i++) {
    dis[s][i] = inf;
    inQue[i] = false;
  }
  dis[s][s] = 0;
  queue<int> Q;
  Q.push(s);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = Point[u]; i != -1; i = edge[i].next) {
      int v = edge[i].v;
      if (dis[s][u] + edge[i].len < dis[s][v]) {
        dis[s][v] = dis[s][u] + edge[i].len;
        if (!inQue[v]) {
          inQue[v] = true;
          Q.push(v);
        }
      }
    }
    inQue[u] = false;
  }
}
int main() {
  int u, v;
  scanf("%d%d%d%d", &N, &M, &u, &v);
  clean();
  for (int i = 1; i <= M; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    insert(u, v, w);
    insert(v, u, w);
  }
  for (int i = 1; i <= N; i++) spfa(i);
  clean();
  for (int i = 1; i <= N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    for (int j = 1; j <= N; j++)
      if (dis[i][j] <= x) insert(i, j, y);
  }
  spfa(u);
  if (dis[u][v] == inf) dis[u][v] = -1;
  printf("%I64d\n", dis[u][v]);
  return 0;
}
