#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long int, long long int> &a,
          pair<long long int, long long int> &b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m, d;
  cin >> n >> m >> d;
  pair<long long int, long long int> py[n], in[m];
  for (int i = 0; i < n; i++) cin >> py[i].first >> py[i].second;
  for (int i = 0; i < m; i++) cin >> in[i].first >> in[i].second;
  sort(py, py + n, comp);
  sort(in, in + m, comp);
  int p1 = 0, p2 = 1;
  long long int sm = py[0].first + in[0].first;
  long long int w = py[0].second + in[0].second;
  if (w > d) {
    cout << "0\n";
    return 0;
  }
  long long int ans = sm;
  while (p2 < m) {
    sm += in[p2].first;
    w += in[p2].second;
    if (w <= d) ans = sm;
    p2++;
  }
  p2 = m - 1;
  while (p1 != n - 1) {
    p1++;
    sm += py[p1].first;
    w += py[p1].second;
    while (w > d and p2 > 0) {
      sm -= in[p2].first;
      w -= in[p2].second;
      p2--;
    }
    if (w <= d) ans = max(ans, sm);
  }
  cout << ans << "\n";
  return 0;
}
