#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > a, b;
int n, m;
long long d;
bool cmp(const pair<long long, long long>& x,
         const pair<long long, long long>& y) {
  if (x.second != y.second) return x.second > y.second;
  return x.first < y.first;
}
int get_ind(long long val) {
  int l = 0, r = m - 1;
  while (l < r) {
    int m = (l + r + 1) >> 1;
    if (b[m].first <= val)
      l = m;
    else
      r = m - 1;
  }
  if (b[l].first <= val)
    return l;
  else
    return -1;
}
void solve() {
  scanf("%d%d%lld", &n, &m, &d);
  a.resize(n);
  b.resize(m);
  for (int(i) = 0; (i) < (n); ++(i))
    scanf("%lld%lld", &a[i].second, &a[i].first);
  for (int(i) = 0; (i) < (m); ++(i))
    scanf("%lld%lld", &b[i].second, &b[i].first);
  sort(a.begin(), a.end(), cmp);
  sort(b.begin(), b.end(), cmp);
  for (int i = 1; i < n; ++i) {
    a[i].first += a[i - 1].first;
    a[i].second += a[i - 1].second;
  }
  for (int i = 1; i < m; ++i) {
    b[i].first += b[i - 1].first;
    b[i].second += b[i - 1].second;
  }
  long long ans = 0;
  for (int(i) = 0; (i) < (n); ++(i)) {
    long long w = a[i].first, c = a[i].second;
    if (w >= d) break;
    int j = get_ind(d - w);
    if (j != -1) ans = max(ans, c + b[j].second);
  }
  printf("%lld", ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
