#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 1111;
int a[N], b[N];
int n;

int solve() {
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i] >> b[i];
    }
    int ans = 1e9;
    rep(i, 1, n) {
        rep(j, 1, n) {
            int cur = i == j ? a[i] + b[j] : max(a[i], b[j]);
            ans = min(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}

//
#include <bits/stdc++.h>
using namespace std;
#define F first 
#define S second
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;

int main ()
{
    ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0);
    ll n, m, q;
    cin >> n >> m >> q;
    pair<ll, ll> a[n], b[m];
    for (auto& x : a) cin >> x.S >> x.F;
    for (ll i = 0; i < m; ++i)
    {
        cin >> b[i].F;
        b[i].S = i + 1;
    }
    sort (a, a + n, greater<pair<ll, ll>> ());
    sort (b, b + m);
    while (q--)
    {
        ll l, r, v = 0;
        cin >> l >> r;
        unordered_set<ll> s;
        for (ll i = 0; i < n; ++i)
        {
            for (ll j = 0; j < m; ++j)
            {
                if (s.count (b[j].S) || (b[j].S >= l && b[j].S <= r)) continue;
                if (b[j].F >= a[i].S)
                {
                    v += a[i].F;
                    s.insert (b[j].S);
                    break;
                }
            }
        }
        cout << v << "\n";
    }
}

