#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
const int MAXM = 100000;
int N, M, D;
int physicsWidth[MAXN], informaticsWidth[MAXM], physicsSignificance[MAXN],
    informaticsSignificance[MAXM];
struct Cup {
  int width;
  int significance;
  const bool operator<(const Cup &other) const {
    if (significance == other.significance) {
      return width < other.width;
    }
    return significance > other.significance;
  }
} physics[MAXN], informatics[MAXM];
void init() {
  scanf("%d %d %d", &N, &M, &D);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &physics[i].significance, &physics[i].width);
  }
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &informatics[i].significance, &informatics[i].width);
  }
}
void presolve() {
  sort(physics, physics + N);
  sort(informatics, informatics + M);
}
long long solve() {
  int pIdx = 1, iIdx = 1;
  long long totalWidth = physics[0].width + informatics[0].width;
  long long totalSignificance =
      physics[0].significance + informatics[0].significance;
  if (totalWidth > D) return 0;
  while (iIdx < M && totalWidth + informatics[iIdx].width <= D) {
    totalWidth += informatics[iIdx].width;
    totalSignificance += informatics[iIdx].significance;
    iIdx++;
  }
  long long maxSignificance = totalSignificance;
  while (pIdx < N) {
    totalWidth += physics[pIdx].width;
    totalSignificance += physics[pIdx].significance;
    pIdx++;
    while (totalWidth > D) {
      if (iIdx <= 1) return maxSignificance;
      iIdx--;
      totalWidth -= informatics[iIdx].width;
      totalSignificance -= informatics[iIdx].significance;
    }
    if (totalSignificance > maxSignificance) {
      ;
    }
    maxSignificance = max(maxSignificance, totalSignificance);
  }
  return maxSignificance;
}
int main() {
  init();
  presolve();
  cout << solve() << "\n";
  return 0;
}
