#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3;
int n, m, k, res, sum;
int a[maxn + 5], b[maxn + 5], c[maxn + 5];
int r[maxn + 5], need[maxn + 5], use[maxn + 5];
vector<int> g[maxn + 5];
priority_queue<pair<int, int> > q;
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) scanf("%d %d %d", &a[i], &b[i], &c[i]);
  for (int i = 1; i <= n; ++i) r[i] = i;
  for (int i = 1, u, v; i <= m; ++i) {
    scanf("%d %d", &u, &v);
    r[v] = max(r[v], u);
  }
  need[n] = a[n];
  for (int i = n - 1; i >= 1; --i) need[i] = max(a[i], need[i + 1] - b[i]);
  sum = k;
  for (int i = 1; i <= n; i++) {
    if (sum < a[i]) {
      puts("-1");
      return 0;
    }
    sum += b[i];
  }
  sum = k;
  for (int i = 1; i <= n; i++) {
    use[i] = sum + b[i] - need[i + 1];
    sum = need[i + 1];
    q.push(pair<int, int>(c[i], i));
  }
  while (!q.empty()) {
    int val = q.top().first, x = q.top().second;
    q.pop();
    int y = r[x];
    while (use[y] == 0 && y > 0) --y;
    if (y == 0) continue;
    --use[y];
    res += val;
  }
  printf("%d\n", res);
  return 0;
}
