func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5010;   inline int read() {     int s = 0, w = 1;     register char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();     return s * w;   }   int n, m, K;   int a[N], b[N], c[N], dp[N][N];   struct Node {     int x, w;   } g[N];   inline bool cp(Node x, Node y) { return x.w < y.w; }   signed main() {     n = read(), m = read(), K = read();     for (register int i = 1; i <= n; i++)       a[i] = read(), b[i] = read(), c[i] = read(), g[i].x = g[i].w = i;     for (register int i = 1; i <= m; i++) {       int u, v;       u = read(), v = read();       g[v].w = max(g[v].w, u);     }     sort(g + 1, g + 1 + n, cp);     int now = 1;     while (!g[now].w) now++;     memset(dp, -0x3f, sizeof(dp));     for (register int i = 0; i <= K; i++) dp[0][i] = 0;     int qwq = K;     for (register int i = 1; i <= n; i++) {       if (qwq < a[i]) {         puts( -1 );         return 0;       }       qwq += b[i];       for (register int j = a[i]; j <= 5000 - b[i]; j++)         dp[i][j + b[i]] = max(dp[i][j + b[i]], dp[i - 1][j]);       while (now <= n && g[now].w == i) {         for (register int j = 1; j <= 5000; j++)           dp[i][j - 1] = max(dp[i][j - 1], dp[i][j] + c[g[now].x]);         now++;       }     }     int res = 0;     for (register int i = 0; i <= 5000; i++) res = max(res, dp[n][i]);     printf( %d n , res);     return 0;   }   