#include <bits/stdc++.h>
using namespace std;
int n, m, st, ed, i, j, ep = 1, h[1005];
long long d[1005][1005], dis[1005];
queue<int> q;
struct node {
  int y, ne, v;
} e[1000005];
void add(int a, int b, int v) {
  e[ep].y = b;
  e[ep].v = v;
  e[ep].ne = h[a];
  h[a] = ep;
  ep++;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &st, &ed);
  for (i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    add(a, b, c);
    add(b, a, c);
  }
  memset(d, 0x3f, sizeof(d));
  for (i = 1; i <= n; i++) {
    d[i][i] = 0;
    q.push(i);
    while (!q.empty()) {
      int s = q.front();
      q.pop();
      for (j = h[s]; j; j = e[j].ne) {
        if (d[i][s] + e[j].v < d[i][e[j].y]) {
          d[i][e[j].y] = d[i][s] + e[j].v;
          q.push(e[j].y);
        }
      }
    }
  }
  memset(h, 0, sizeof(h));
  ep = 1;
  for (i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    for (j = 1; j <= n; j++)
      if (d[i][j] <= a && i != j) add(i, j, b);
  }
  memset(dis, 0x3f, sizeof(dis));
  dis[st] = 0;
  q.push(st);
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    for (i = h[s]; i; i = e[i].ne) {
      if (dis[s] + e[i].v < dis[e[i].y]) {
        dis[e[i].y] = dis[s] + e[i].v;
        q.push(e[i].y);
      }
    }
  }
  if (dis[ed] < (1LL << 60))
    printf("%I64d\n", dis[ed]);
  else
    puts("-1");
}
