#include <bits/stdc++.h>
using namespace std;
const long long maxn = 100003;
const long long maxlen = 2502;
const long long maxseg = 262144;
const long long mod = 1e9 + 7;
const double pi = 3.141592653589793238462643383279502884;
const double eps = 1e-5;
long long n, m, d;
pair<long long, long long> phys[maxn];
pair<long long, long long> info[maxn];
long long pref_zn_phys[maxn];
long long pref_shir_phys[maxn];
long long pref_zn_info[maxn];
long long pref_shir_info[maxn];
bool comp(pair<long long, long long> &a, pair<long long, long long> &b) {
  return a.first > b.first || (a.first == b.first && a.second < b.second);
}
int main() {
  cin >> n >> m >> d;
  for (int i = 0; i < n; ++i) cin >> phys[i].first >> phys[i].second;
  for (int j = 0; j < m; ++j) cin >> info[j].first >> info[j].second;
  sort(phys, phys + n, comp);
  sort(info, info + m, comp);
  if (phys[0].second + info[0].second > d) {
    cout << 0;
    return 0;
  }
  pref_zn_phys[0] = phys[0].first;
  pref_shir_phys[0] = phys[0].second;
  for (int i = 1; i < n; ++i) {
    pref_zn_phys[i] = pref_zn_phys[i - 1] + phys[i].first;
    pref_shir_phys[i] = pref_shir_phys[i - 1] + phys[i].second;
  }
  pref_zn_info[0] = info[0].first;
  pref_shir_info[0] = info[0].second;
  for (int i = 1; i < m; ++i) {
    pref_zn_info[i] = pref_zn_info[i - 1] + info[i].first;
    pref_shir_info[i] = pref_shir_info[i - 1] + info[i].second;
  }
  long long best = 0;
  for (int i = 0; i < n; ++i) {
    int left = 0;
    int right = m;
    while (right - left != 1) {
      int mid = (right + left) / 2;
      if (pref_shir_phys[i] + pref_shir_info[mid] <= d)
        left = mid;
      else
        right = mid;
    }
    if (pref_shir_phys[i] + pref_shir_info[left] <= d)
      best = max(best, pref_zn_phys[i] + pref_zn_info[left]);
  }
  cout << best;
  return 0;
}
