#include <bits/stdc++.h>
using namespace std;
int n, m, d;
const int N = 100100;
struct node {
  long long c, w;
  bool operator<(const node t) const {
    if (c == t.c) return w < t.w;
    return c > t.c;
  }
} a[N], b[N];
int main() {
  scanf("%d%d%d", &n, &m, &d);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &a[i].c, &a[i].w);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= m; i++) scanf("%lld%lld", &b[i].c, &b[i].w);
  sort(b + 1, b + m + 1);
  for (int i = 1; i <= n; i++) a[i].c += a[i - 1].c, a[i].w += a[i - 1].w;
  for (int i = 1; i <= m; i++) b[i].c += b[i - 1].c, b[i].w += b[i - 1].w;
  long long s = 0;
  for (int i = 1; i <= n; i++) {
    long long t = d - a[i].w;
    int l = 0, r = m;
    while (l < r) {
      int mid = (l + r + 1) >> 1;
      if (b[mid].w <= t)
        l = mid;
      else
        r = mid - 1;
    }
    if (b[l].w > t || l == 0) continue;
    s = max(s, a[i].c + b[l].c);
  }
  cout << s;
}
