#include <bits/stdc++.h>
using namespace std;
void read(int &val) {
  int x = 0;
  int bz = 1;
  char c;
  for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar())
    ;
  if (c == '-') {
    bz = -1;
    c = getchar();
  }
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
  val = x * bz;
}
const int INF = 0x3f3f3f3f;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
int n, m, k;
int a[maxn], b[maxn], c[maxn];
int fa[maxn];
struct node {
  int v, id;
  bool operator<(const node b) const {
    if (v == b.v) return id < b.id;
    return v < b.v;
  }
};
priority_queue<node> q;
int mi[maxn];
int nw[maxn];
bool check() {
  for (int i = n; i >= 1; i--) {
    mi[i] = max(a[i], mi[i + 1] - b[i]);
  }
  nw[0] = k;
  for (int i = 1; i <= n; i++) {
    nw[i] = nw[i - 1] + b[i];
  }
  for (int i = 1; i <= n; i++) {
    if (nw[i - 1] < mi[i]) return false;
  }
  return true;
}
int solve() {
  int ans = 0;
  while (!q.empty()) {
    node top = q.top();
    q.pop();
    int id = top.id, flag = 1;
    for (int i = fa[id]; i <= n; i++) {
      if (nw[i] - 1 < mi[i + 1]) {
        flag = 0;
        break;
      }
    }
    if (!flag) continue;
    ans += top.v;
    for (int i = fa[id]; i <= n; i++) nw[i]--;
  }
  return ans;
}
int main() {
  read(n);
  read(m);
  read(k);
  for (int i = 1; i <= n; i++) read(a[i]), read(b[i]), read(c[i]), fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int u, v;
    read(u);
    read(v);
    fa[v] = max(fa[v], u);
  }
  if (!check()) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    q.push(node{c[i], i});
  }
  printf("%d\n", solve());
  return 0;
}
