#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 5, M = 3e5 + 5;
int n, m, k, u, v, ans;
int a[N], b[N], c[N], maxn[N];
int cnt, head[N];
struct edge {
  int next, to;
} e[M];
inline void add(int u, int v) {
  cnt++;
  e[cnt].next = head[u];
  e[cnt].to = v;
  head[u] = cnt;
}
priority_queue<int, vector<int>, greater<int> > q;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (register int i = 1; i <= n; ++i) scanf("%d%d%d", &a[i], &b[i], &c[i]);
  for (register int i = 1; i <= n; ++i) maxn[i] = i;
  for (register int i = 1; i <= m; ++i) {
    scanf("%d%d", &u, &v), add(u, v);
    maxn[v] = max(maxn[v], u);
  }
  for (register int i = 1; i <= n; ++i) {
    while (k < a[i]) {
      if (q.size()) {
        int u = q.top();
        q.pop();
        ans -= u;
        k++;
      } else {
        puts("-1");
        return 0;
      }
    }
    k += b[i];
    if (maxn[i] == i) {
      if (k)
        k--, ans += c[i], q.push(c[i]);
      else if (q.size()) {
        if (c[i] > q.top()) {
          ans -= q.top(), q.pop();
          ans += c[i], q.push(c[i]);
        }
      }
    }
    for (register int j = head[i]; j; j = e[j].next)
      if (maxn[e[j].to] == i) {
        if (k)
          k--, ans += c[e[j].to], q.push(c[e[j].to]);
        else if (q.size()) {
          if (c[e[j].to] > q.top()) {
            ans -= q.top(), q.pop();
            ans += c[e[j].to], q.push(c[e[j].to]);
          }
        }
      }
  }
  printf("%d\n", ans);
  return 0;
}
