#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, d;
  cin >> n >> m >> d;
  vector<pair<long long, long long>> a(n), b(m);
  for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  for (int i = 0; i < m; ++i) cin >> b[i].first >> b[i].second;
  sort(a.begin(), a.end(),
       [](const pair<long long, long long>& f,
          const pair<long long, long long>& s) {
         if (f.first == s.first) return f.second < s.second;
         return f.first > s.first;
       });
  sort(b.begin(), b.end(),
       [](const pair<long long, long long>& f,
          const pair<long long, long long>& s) {
         if (f.first == s.first) return f.second < s.second;
         return f.first > s.first;
       });
  vector<long long> prefa(n), prefb(m);
  vector<long long> scorea(n), scoreb(m);
  for (int i = 0; i < n; ++i) {
    prefa[i] = i ? (prefa[i - 1] + a[i].second) : a[i].second;
    scorea[i] = i ? (scorea[i - 1] + a[i].first) : a[i].first;
  }
  for (int i = 0; i < m; ++i) {
    prefb[i] = i ? (prefb[i - 1] + b[i].second) : b[i].second;
    scoreb[i] = i ? (scoreb[i - 1] + b[i].first) : b[i].first;
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (prefa[i] + prefb[0] > d) break;
    int tl = 0, tr = m;
    while (tr - tl > 1) {
      int tm = (tl + tr) / 2;
      if (prefa[i] + prefb[tm] <= d)
        tl = tm;
      else
        tr = tm;
    }
    ans = max(ans, scorea[i] + scoreb[tl]);
  }
  cout << ans;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
