#include <bits/stdc++.h>

#define TASK "robots"
using namespace std;
typedef long long ll;
typedef long double ld;
const ll inf = numeric_limits<ll>::max();
const ll mod = 1000000007;
const ld eps = 1e-7;
const ll maxn = 123456;

ll n, m, p;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    if(strcmp(TASK,"")!=0)
    {
        freopen(TASK".in","r",stdin);
        freopen(TASK".out","w",stdout);
    }
#endif
    cin >> n >> m >> p;
    vector<pair<ll, ll> > x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i].first >> x[i].second;
    }
    vector<pair<ll, ll> > y(m);
    for (int i = 0; i < m; i++)
    {
        cin >> y[i].first >> y[i].second;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    if (p == 0)
    {
        ll cntx = 0;
        for (int i = 0; i < n; i++) cntx += x[i].second;
        set<pair<ll, ll> > st;
        for (int i = 0; i < m; i++)st.insert(make_pair(y[i].second, y[i].first));
        ll ans = 0;
        for (auto i = st.rbegin(); i != st.rend() && cntx > 0; i++)
        {
            if (cntx >= i->second)
            {
                cntx -= i->second;
                ans += i->second * i->first;
            }
            else
            {
                cntx = 0;
                ans += cntx * i->first;
            }
        }
        cout << ans;
        return 0;
    }
    return 0;
}