#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
const long long INF = 0x3fffffff;
int n, m, st, ed;
int vis[1005];
long long cost[1005];
long long ans;
struct node {
  int v;
  long long w;
  int flag;
  node(){};
  node(int _v, int _w) : v(_v), w(_w){};
  bool friend operator<(node n1, node n2) { return n1.w >= n2.w; }
} cur, tmp;
vector<node> v[1005];
vector<node> e[1005];
void spfa2(int root) {
  for (int i = 0; i < 1005; i++) cost[i] = INF * 1000000;
  cost[root] = 0;
  queue<int> Q;
  while (!Q.empty()) Q.pop();
  Q.push(root);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = 0; i < v[u].size(); i++) {
      node cur2 = v[u][i];
      if (cost[cur2.v] > cost[u] + cur2.w) {
        cost[cur2.v] = cost[u] + cur2.w;
        Q.push(cur2.v);
      }
    }
  }
}
void spfa(int root) {
  for (int i = 0; i < 1005; i++) cost[i] = INF * 1000000;
  cost[root] = 0;
  queue<int> Q;
  while (!Q.empty()) Q.pop();
  Q.push(root);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = 0; i < e[u].size(); i++) {
      node cur2 = e[u][i];
      if (cost[cur2.v] > cost[u] + cur2.w) {
        cost[cur2.v] = cost[u] + cur2.w;
        Q.push(cur2.v);
      }
    }
  }
}
int main() {
  while (scanf("%d %d", &n, &m) != EOF) {
    for (int i = 0; i < 1005; i++) {
      v[i].clear();
      e[i].clear();
    }
    scanf("%d %d", &st, &ed);
    int a, b, c;
    for (int i = 0; i < m; i++) {
      scanf("%d %d %d", &a, &b, &c);
      v[a].push_back(node(b, c));
      v[b].push_back(node(a, c));
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d %d", &a, &b);
      e[i].push_back(node(i, 0));
      spfa2(i);
      for (int j = 1; j <= n; j++) {
        if (cost[j] <= a) {
          e[i].push_back(node(j, b));
        }
      }
    }
    if (st == ed) {
      printf("0\n");
      continue;
    }
    spfa(st);
    if (cost[ed] != INF * 1000000)
      printf("%lld\n", cost[ed]);
    else
      printf("-1\n");
  }
  return 0;
}
