#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 9;
struct node {
  int a, b, c;
} p[N];
int nex[N];
priority_queue<int> pre[N];
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) scanf("%d %d %d", &p[i].a, &p[i].b, &p[i].c);
  for (int i = 1; i <= n; ++i) nex[i] = i;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    nex[v] = max(nex[v], u);
  }
  for (int i = 1; i <= n; ++i) {
    pre[nex[i]].push(p[i].c);
  }
  int sum = k;
  int ans = 0;
  priority_queue<int, vector<int>, greater<int> > q;
  for (int i = 1; i <= n; ++i) {
    if (sum < p[i].a) {
      while (!q.empty() && sum < p[i].a) {
        ans -= q.top();
        q.pop();
        ++sum;
      }
      if (sum < p[i].a) {
        printf("-1");
        return 0;
      }
    }
    sum += p[i].b;
    for (; (!pre[i].empty()) && sum; ++k) {
      ans += pre[i].top();
      --sum;
      q.push(pre[i].top());
      pre[i].pop();
    }
    if (sum == 0) {
      while ((!pre[i].empty()) && (!q.empty()) && pre[i].top() > q.top()) {
        ans += pre[i].top() - q.top();
        q.pop();
        q.push(pre[i].top());
        pre[i].pop();
      }
    }
  }
  printf("%d", ans);
  return 0;
}
