#include <bits/stdc++.h>
using namespace std;
const long long int N = 5005;
const long long int mod1 = 998244353;
const long long int mod = 1e9 + 7;
struct dat {
  long long int l, r, i;
};
bool cmp(long long int a, long long int b) { return a > b; }
long long int a[N];
long long int b[N];
long long int c[N];
vector<long long int> t[N];
vector<long long int> g[N];
void solve() {
  long long int n, m;
  cin >> n >> m >> b[0];
  for (int i = (1); i <= (n); ++i) cin >> a[i] >> b[i] >> c[i];
  for (int i = (1); i <= (m); ++i) {
    long long int x, y;
    cin >> x >> y;
    t[y].push_back(x);
  }
  for (int i = (1); i <= (n); ++i) {
    long long int maxi = 0;
    t[i].push_back(i);
    for (auto v : t[i]) maxi = max(maxi, v);
    g[maxi].push_back(c[i]);
  }
  for (int i = (1); i <= (n); ++i) sort(g[i].begin(), g[i].end(), cmp);
  long long int ans = 0;
  long long int sum = b[0];
  priority_queue<long long int> q;
  for (int i = (1); i <= (n); ++i) {
    if (sum + q.size() < a[i]) {
      cout << -1;
      return;
    }
    while (sum < a[i]) {
      q.pop();
      ++sum;
    }
    sum += b[i];
    long long int t = 0;
    int j;
    for (j = 0; j < min(sum, (long long int)g[i].size()); ++j) {
      ++t;
      q.push(-g[i][j]);
    }
    sum -= t;
    if (sum == 0) {
      while (j < g[i].size() && q.size() && g[i][j] > -q.top()) {
        q.pop();
        q.push(-g[i][j]);
        ++j;
      }
    }
  }
  while (q.size()) {
    ans -= q.top();
    q.pop();
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
