//****** @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;
}
if(dp[pos][k]!=-1){
return dp[pos][k];
}
int 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 dp[pos][k]=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;
}
Ly8qKioqKiogQG1kYXptYXQ5ICoqKioqKioqKioKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBpbnQgbG9uZyBsb25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z1tYXgoYW5zLHRlbXArcmVjKHBvcysxLGstY250KSk7CiAgICAgICAgICAgICAgICBjbnQrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHJldHVybiBkcFtwb3NdW2tdPWFuczsKfQoKdm9pZCBzb2x2ZSgpIHsKICAgIGludCBtLGs7Y2luPj5uPj5tPj5rOwogICAgZm9yKGludCBpPTA7aTxuO2krKyl7CiAgICAgICAgY2luPj5ub2RlW2ldLmE+Pm5vZGVbaV0uYj4+bm9kZVtpXS5wcm9maXQ7CiAgICB9CiAgICBtYXA8aW50LGludD4gbXA7CiAgICBmb3IoaW50IGk9MDtpPG07aSsrKXsKICAgICAgICBpbnQgdSx2O2Npbj4+dT4+djsKICAgICAgICB1LS07di0tOwogICAgICAgIG1wW3ZdPW1heChtcFt2XSx1KTsKICAgIH0KICAgIGZvcihpbnQgaT0wO2k8bjtpKyspewogICAgICAgIG1wW2ldPW1heChpLG1wW2ldKTsKICAgIH0KICAgIGZvcihhdXRvIHg6bXApewogICAgICAgIHNhdmVbeC5TXS5FQihub2RlW3guRl0ucHJvZml0LHguRik7CiAgICB9CgogICAgZm9yKGF1dG8mIHg6c2F2ZSl7CiAgICAgICAgc29ydChBTEwoeC5TKSxncmVhdGVyPHBhaXI8aW50LGludD4+KCkpOwogICAgfQogICAgbWVtc2V0KGRwLC0xLCBzaXplb2YoZHApKTsKICAgIGNvdXQ8PG1heCgtMWxsLHJlYygwLGspKTw8ZW5kbDsKCn0KaW50MzJfdCBtYWluKCkgewogICAgSU9TOwogICAgaW50IHRlc3QgPSAxOwovLyAgICBjaW4gPj4gdGVzdDsKICAgIGZvcihpbnQgaT0xO2k8PXRlc3Q7aSsrKXsKICAgICAgICBzb2x2ZSgpOwogICAgfQogICAgcmV0dXJuIDA7Cn0KaW50IGZhc3RfcG93KGludCB4LCBpbnQgeSwgaW50IHApIHsKICAgIGludCByZXMgPSAxOwogICAgeCA9IHggJSBwOwogICAgd2hpbGUgKHkgPiAwKSB7CiAgICAgICAgaWYgKHkgJiAxKQogICAgICAgICAgICByZXMgPSAocmVzICogeCkgJSBwOwogICAgICAgIHkgPSB5ID4+IDE7CiAgICAgICAgeCA9ICh4ICogeCkgJSBwOwogICAgfQogICAgcmV0dXJuIHJlczsKfQ==