#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k, tot;
  cin >> n >> m >> k;
  tot = k;
  vector<int> a(n + 1), b(n + 1), late(n + 1), fr(n + 1), req(n + 2);
  vector<pair<int, int> > c(n + 1);
  int flag = 0;
  for (int i = 1; i <= (int)(n); ++i) {
    cin >> a[i] >> b[i] >> c[i].first;
    c[i].second = i;
    if (tot < a[i]) {
      flag = 1;
    } else {
      tot += b[i];
    }
    late[i] = i;
  }
  for (int i = 0; i < (int)(m); ++i) {
    int u, v;
    cin >> u >> v;
    late[v] = max(late[v], u);
  }
  if (flag)
    cout << -1;
  else {
    for (int i = n; i >= 1; i--) {
      if (i == n)
        req[i] = 0;
      else
        req[i] = max(a[i + 1], req[i + 1] - b[i + 1]);
    }
    tot = k;
    for (int i = 1; i <= (int)(n); ++i) {
      tot += b[i];
      fr[i] = tot - req[i];
      tot = req[i];
    }
    sort(c.begin() + 1, c.end(),
         [](pair<int, int> a, pair<int, int> b) { return a.first > b.first; });
    int ans = 0;
    for (int i = 1; i <= (int)(n); ++i) {
      int val = c[i].first, x = c[i].second;
      int y = late[x];
      while (!fr[y] && y > 0) y--;
      if (y == 0) continue;
      fr[y]--;
      ans += val;
    }
    cout << ans;
  }
  return 0;
}
