#include <bits/stdc++.h>
using namespace std;
int n, m;
long long d;
vector<long long> cb, wb;
int bsearch(long long x) {
  int l = 0, r = m;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (wb[mid] <= x)
      l = mid;
    else
      r = mid;
  }
  for (int i = r; i >= l; i--)
    if (wb[i] <= x) return i;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> d;
  cb.resize(m + 1);
  wb.resize(m + 1);
  vector<pair<long long, long long>> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i].first >> a[i].second;
    a[i].first *= -1;
  }
  vector<pair<long long, long long>> b(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> b[i].first >> b[i].second;
    b[i].first *= -1;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < (int)(n); i++) a[i].first *= -1;
  for (int i = 0; i < (int)(m); i++) b[i].first *= -1;
  vector<long long> ca(n + 1), wa(n + 1);
  ca[0] = 0;
  wa[0] = 0;
  for (int i = 0; i < n; i++) {
    ca[i + 1] = ca[i] + a[i].first;
    wa[i + 1] = wa[i] + a[i].second;
  }
  cb[0] = 0;
  wb[0] = 0;
  for (int i = 0; i < m; i++) {
    cb[i + 1] = cb[i] + b[i].first;
    wb[i + 1] = wb[i] + b[i].second;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long cur = d - wa[i];
    long long cnt = bsearch(cur);
    if (cnt >= 1) ans = max(ans, ca[i] + cb[cnt]);
  }
  cout << ans << endl;
  return 0;
}
