#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v;
  int w;
};
struct vertex {
  int t, c;
};
struct node {
  int id;
  long long int dis;
};
node h[1001] = {};
long long int cost[1001][1001] = {};
int h_p[1001] = {};
int h_size;
const long long mmax = 1125899906842624;
void decreasekey(int k) {
  while (h[k].dis < h[k / 2].dis) {
    swap(h[k], h[k / 2]);
    swap(h_p[h[k].id], h_p[h[k / 2].id]);
    k /= 2;
  }
}
void downheap(int k) {
  int j;
  node tmp = h[k];
  while (2 * k <= h_size) {
    j = 2 * k;
    if (j <= h_size && h[j].dis > h[j + 1].dis) ++j;
    if (tmp.dis <= h[j].dis) break;
    h[k] = h[j];
    h_p[h[k].id] = k;
    k = j;
  }
  h[k] = tmp;
  h_p[tmp.id] = k;
}
node extract_min() {
  node minimum = h[1];
  h[1] = h[h_size];
  h_p[h[1].id] = 1;
  --h_size;
  downheap(1);
  return minimum;
}
void create_heap(int s) {
  for (int i = 1; i <= h_size; ++i) {
    h[i].id = i;
    h[i].dis = mmax;
    h_p[i] = i;
  }
  h[s].dis = 0;
  swap(h[s], h[1]);
  h_p[s] = 1;
  h_p[1] = s;
}
int main() {
  int m, n, u, v, w, t, c, x, y;
  long long int arr[1001] = {};
  list<edge> e[1001];
  edge e_tmp;
  vertex taxi[1001];
  long long int d[1001] = {};
  h[0].dis = -1;
  node now;
  cin >> n >> m >> x >> y;
  for (int i = 0; i < m; ++i) {
    cin >> u >> v >> w;
    e_tmp.v = v;
    e_tmp.w = w;
    e[u].push_back(e_tmp);
    e_tmp.v = u;
    e[v].push_back(e_tmp);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> t >> c;
    taxi[i].t = t;
    taxi[i].c = c;
  }
  for (int i = 1; i <= n; ++i) {
    h_size = n;
    create_heap(i);
    for (int k = 1; k <= n; ++k) {
      arr[k] = mmax;
      cost[i][k] = mmax;
    }
    arr[i] = 0;
    cost[i][i] = 0;
    while (h_size != 1) {
      now = extract_min();
      if (now.dis > taxi[i].t) break;
      for (list<edge>::iterator it = e[now.id].begin(); it != e[now.id].end();
           ++it) {
        if (arr[it->v] > arr[now.id] + it->w) {
          arr[it->v] = arr[now.id] + it->w;
          h[h_p[it->v]].dis = arr[it->v];
          decreasekey(h_p[it->v]);
          if (arr[it->v] <= taxi[i].t) cost[i][it->v] = taxi[i].c;
        }
      }
    }
  }
  h_size = n;
  create_heap(x);
  for (int i = 1; i <= n; ++i) arr[i] = mmax;
  arr[x] = 0;
  while (h_size != 1) {
    now = extract_min();
    for (int i = 1; i <= n; ++i) {
      if (arr[i] > arr[now.id] + cost[now.id][i]) {
        arr[i] = arr[now.id] + cost[now.id][i];
        h[h_p[i]].dis = arr[i];
        decreasekey(h_p[i]);
      }
    }
  }
  if (arr[y] != mmax)
    cout << arr[y] << endl;
  else
    cout << -1 << endl;
}
