//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);
map<int,vector<pair<int,int>>> save;
class Node{
public:
int a,b,profit;
};
Node node[5001];
int dp[5001][5001];
int n;
int rec(int pos,int k){
if(pos==n){
return 0;
}
int& ans=dp[pos][k]; // refernce created
if(ans!=-1)return ans;
ans=INT_MIN;
if(k>=node[pos].a){
k+=node[pos].b;
ans=max(ans,rec(pos+1,k));
int cnt=1;
int temp=0;
for(auto x:save[pos]){
if(k-cnt>=0){
temp+=x.F;
ans=max(ans,temp+rec(pos+1,k-cnt));
cnt++;
}
}
}
return ans;
}
void solve() {
int m,k;cin>>n>>m>>k;
for(int i=0;i<n;i++){
cin>>node[i].a>>node[i].b>>node[i].profit;
}
map<int,int> mp;
for(int i=0;i<m;i++){
int u,v;cin>>u>>v;
u--;v--;
mp[v]=max(mp[v],u);
}
for(int i=0;i<n;i++){
mp[i]=max(i,mp[i]);
}
for(auto x:mp){
save[x.S].EB(node[x.F].profit,x.F);
}
for(auto& x:save){
sort(ALL(x.S),greater<pair<int,int>>());
}
memset(dp,-1, sizeof(dp));
cout<<max(-1ll,rec(0,k))<<endl;
}
int32_t main() {
IOS;
int test = 1;
// cin >> test;
for(int i=1;i<=test;i++){
solve();
}
return 0;
}
int fast_pow(int x, int y, int p) {
int res = 1;
x = x % p;
while (y > 0) {
if (y & 1)
res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
Ly8qKioqKiogQG1kYXptYXQ5ICoqKioqKioqKioKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBpbnQgbG9uZyBsb25nCiN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gICAgICAgICAgIGFucz1tYXgoYW5zLHRlbXArcmVjKHBvcysxLGstY250KSk7CiAgICAgICAgICAgICAgICBjbnQrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHJldHVybiBhbnM7Cn0KCnZvaWQgc29sdmUoKSB7CiAgICBpbnQgbSxrO2Npbj4+bj4+bT4+azsKICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIGNpbj4+bm9kZVtpXS5hPj5ub2RlW2ldLmI+Pm5vZGVbaV0ucHJvZml0OwogICAgfQogICAgbWFwPGludCxpbnQ+IG1wOwogICAgZm9yKGludCBpPTA7aTxtO2krKyl7CiAgICAgICAgaW50IHUsdjtjaW4+PnU+PnY7CiAgICAgICAgdS0tO3YtLTsKICAgICAgICBtcFt2XT1tYXgobXBbdl0sdSk7CiAgICB9CiAgICBmb3IoaW50IGk9MDtpPG47aSsrKXsKICAgICAgICBtcFtpXT1tYXgoaSxtcFtpXSk7CiAgICB9CiAgICBmb3IoYXV0byB4Om1wKXsKICAgICAgICBzYXZlW3guU10uRUIobm9kZVt4LkZdLnByb2ZpdCx4LkYpOwogICAgfQoKICAgIGZvcihhdXRvJiB4OnNhdmUpewogICAgICAgIHNvcnQoQUxMKHguUyksZ3JlYXRlcjxwYWlyPGludCxpbnQ+PigpKTsKICAgIH0KICAgIG1lbXNldChkcCwtMSwgc2l6ZW9mKGRwKSk7CiAgICBjb3V0PDxtYXgoLTFsbCxyZWMoMCxrKSk8PGVuZGw7Cgp9CmludDMyX3QgbWFpbigpIHsKICAgIElPUzsKICAgIGludCB0ZXN0ID0gMTsKLy8gICAgY2luID4+IHRlc3Q7CiAgICBmb3IoaW50IGk9MTtpPD10ZXN0O2krKyl7CiAgICAgICAgc29sdmUoKTsKICAgIH0KICAgIHJldHVybiAwOwp9CmludCBmYXN0X3BvdyhpbnQgeCwgaW50IHksIGludCBwKSB7CiAgICBpbnQgcmVzID0gMTsKICAgIHggPSB4ICUgcDsKICAgIHdoaWxlICh5ID4gMCkgewogICAgICAgIGlmICh5ICYgMSkKICAgICAgICAgICAgcmVzID0gKHJlcyAqIHgpICUgcDsKICAgICAgICB5ID0geSA+PiAxOwogICAgICAgIHggPSAoeCAqIHgpICUgcDsKICAgIH0KICAgIHJldHVybiByZXM7Cn0=