#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int n, m, k;
int a[N], b[N], c[N];
int lst[N];
long long ans;
vector<int> es[N];
struct cmp {
  inline bool operator()(const int &x, const int &y) { return c[x] > c[y]; }
};
priority_queue<int, vector<int>, cmp> heap;
signed main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    lst[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", a + i, b + i, c + i);
  }
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d %d", &u, &v);
    lst[v] = max(lst[v], u);
  }
  for (int i = 1; i <= n; i++) {
    es[lst[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    while (!heap.empty() && k < a[i]) {
      int cur = heap.top();
      k++;
      ans -= c[cur];
      heap.pop();
    }
    if (k < a[i]) {
      puts("-1");
      return 0;
    }
    k += b[i];
    for (int j = 0; j < es[i].size(); j++) {
      int v = es[i][j];
      if (k == 0 && !heap.empty() && c[heap.top()] < c[v]) {
        int cur = heap.top();
        heap.pop();
        ans -= c[cur];
        k++;
      }
      if (k == 0) {
        continue;
      }
      k--;
      ans += c[v];
      heap.push(v);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
