#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > first;
vector<pair<long long, long long> > second;
vector<long long> f, s;
bool cmp(pair<long long, long long> z, pair<long long, long long> z1) {
  return z.second < z1.second;
}
int main() {
  int n, m;
  cin >> n >> m;
  long long int k;
  cin >> k;
  for (int i = 0; i < n; i++) {
    long long int a, b;
    cin >> a >> b;
    first.push_back(make_pair(-a, b));
  }
  sort(first.begin(), first.end());
  for (int i = 0; i < n; i++) {
    first[i].first *= -1;
  }
  for (int i = 0; i < n; i++) {
    if (i) {
      first[i].second += first[i - 1].second;
      first[i].first += first[i - 1].first;
    }
  }
  for (int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    second.push_back(make_pair(-a, b));
  }
  sort(second.begin(), second.end());
  for (int i = 0; i < m; i++) {
    second[i].first *= -1;
  }
  for (int i = 0; i < m; i++) {
    if (i) {
      second[i].second += second[i - 1].second;
      second[i].first += second[i - 1].first;
    }
  }
  long long ma = 0;
  for (int i = 0; i < n; i++) {
    swap(first[i].first, first[i].second);
  }
  for (int i = 0; i < m; i++) {
    swap(second[i].first, second[i].second);
  }
  for (int i = 0; i < n; i++) {
    long long int u = k - first[i].first;
    if (u <= 0) {
      break;
    }
    auto it = upper_bound(second.begin(), second.end(),
                          make_pair(u, (long long)1000000000000000000)) -
              second.begin() - 1;
    if (it == -1) {
      continue;
    }
    ma = max(ma, first[i].second + second[it].second);
  }
  cout << ma;
  return 0;
}
