#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e4 + 10;
void file(string s) {
  freopen((s + ".in").c_str(), "r", stdin),
      freopen((s + ".out").c_str(), "w", stdout);
}
long long read() {
  long long f = 1, a = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    a = a * 10 + ch - '0';
    ch = getchar();
  }
  return a * f;
}
long long n, m, k;
long long a[MAXN], b[MAXN], c[MAXN], nxt[MAXN];
vector<long long> pre[MAXN];
priority_queue<long long, vector<long long>, greater<long long> > q;
signed main() {
  n = read(), m = read(), k = read();
  for (long long i = 1; i <= n; ++i) {
    a[i] = read(), b[i] = read(), c[i] = read();
    nxt[i] = i;
  }
  for (long long i = 1; i <= m; ++i) {
    long long x = read(), y = read();
    nxt[y] = max(nxt[y], x);
  }
  for (long long i = 1; i <= n; ++i) {
    pre[nxt[i]].push_back(i);
  }
  long long nown = k, ans = 0;
  for (long long i = 1; i <= n; ++i) {
    while (nown < a[i] && !q.empty()) {
      long long x = q.top();
      q.pop();
      ans -= x;
      nown++;
    }
    if (nown < a[i]) {
      ans = -1;
      break;
    }
    nown += b[i];
    for (long long j = 0; j < pre[i].size(); ++j) {
      long long x = c[pre[i][j]];
      if (nown == 0) {
        if (!q.empty()) {
          long long y = q.top();
          if (y >= x) continue;
          q.pop();
          ans -= y;
          nown++;
        } else {
          continue;
        }
      }
      nown--;
      q.push(x);
      ans += x;
    }
  }
  cout << ans << endl;
  return 0;
}
