#include <bits/stdc++.h>
using namespace std;
int m, n;
long long d;
struct dd {
  long long c;
  long long w;
};
bool cmp(dd a, dd b) { return a.c > b.c || (a.c == b.c && a.w < b.w); }
dd n1[1000001], n2[1000001];
long long sum, sum1, ss;
int main() {
  cin >> n >> m >> d;
  for (int i = 0; i < n; i++) {
    cin >> n1[i].c >> n1[i].w;
  }
  for (int i = 0; i < m; i++) {
    cin >> n2[i].c >> n2[i].w;
  }
  sort(n1, n1 + n, cmp);
  sort(n2, n2 + m, cmp);
  for (int i = 1; i < n; i++) {
    (n1[i].w) += n1[i - 1].w;
    (n1[i].c) += n1[i - 1].c;
  }
  cout << endl;
  for (int i = 1; i < m; i++) {
    (n2[i].w) += n2[i - 1].w;
    (n2[i].c) += n2[i - 1].c;
  }
  long long k = 0;
  for (int i = 0; i < n; i++) {
    if (n1[i].w > d) break;
    ss = d - n1[i].w;
    int l = 0, r = m;
    while (l < r) {
      int mid = (l + r + 1) / 2;
      if (n2[mid].w <= ss && mid < m)
        l = mid;
      else
        r = mid - 1;
    }
    if (n2[l].w > ss) {
      continue;
    }
    sum = max(sum, (n1[i].c + n2[l].c));
  }
l:
  cout << sum;
  return 0;
}
