#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, d;
  cin >> n >> m >> d;
  pair<long long, long long> p1[n], p2[m];
  long long s1 = 0, s2 = 0, c1 = 0, c2 = 0;
  for (int i = 0; i < n; ++i) {
    cin >> p1[i].first >> p1[i].second;
    s1 += p1[i].second;
    c1 += p1[i].first;
    p1[i].second = -p1[i].second;
  }
  for (int i = 0; i < m; ++i) {
    cin >> p2[i].first >> p2[i].second;
    p2[i].second = -p2[i].second;
  }
  sort(p1, p1 + n);
  sort(p2, p2 + m);
  for (int i = 0; i < n; ++i) {
    p1[i].second = -p1[i].second;
  }
  for (int i = 0; i < m; ++i) {
    p2[i].second = -p2[i].second;
  }
  int j = m - 1;
  s2 = p2[m - 1].second;
  c2 = p2[m - 1].first;
  long long N = 0;
  for (int i = 0; i <= n - 1; ++i) {
    while (j > 0 && s1 + s2 + p2[j - 1].second <= d) {
      j--;
      s2 += p2[j].second;
      c2 += p2[j].first;
    }
    if (s1 + s2 <= d) {
      N = max(N, c1 + c2);
    }
    s1 -= p1[i].second;
    c1 -= p1[i].first;
  }
  cout << N;
  return 0;
}
