#include <bits/stdc++.h>
using namespace std;
int n, m, k, a, b, cur, last, tot;
int value[5005];
int extra[5005];
int done[5005];
vector<int> portal[5005];
priority_queue<int> pq;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &a, &b, &value[i]);
    if (k < a) {
      printf("-1\n");
      return 0;
    }
    if (i != 0) {
      extra[i - 1] = k - a;
    }
    k += b;
    portal[i].push_back(i);
  }
  extra[n - 1] = k;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    portal[a].push_back(b);
  }
  for (int i = n - 1 - 1; i >= 0; i--) {
    extra[i] = min(extra[i], extra[i + 1]);
  }
  for (int i = 0; i < n; i++) {
    cur = extra[i];
    extra[i] -= last;
    last = cur;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (auto t : portal[i]) {
      if (!done[t]) {
        done[t] = true;
        pq.push(value[t]);
      }
    }
    for (int j = 0; j < extra[i]; j++) {
      if (pq.size()) {
        tot += pq.top();
        pq.pop();
      } else {
        break;
      }
    }
  }
  printf("%d\n", tot);
  return 0;
}
