#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const int N = 2e5 + 10;
int n, m;
ll s;
struct node{
ll w, v;
}a[N];
int l[N], r[N];
ll ans = LLONG_MAX;
ll sum1[N], sum2[N];
ll Y(ll x)
{
ll sum = 0;
memset(sum1, 0ll, sizeof(sum1));
memset(sum2, 0ll, sizeof(sum2));
for (int i = 1; i <= n; i++)
{
sum1[i] = sum1[i - 1] + (ll)(a[i].w >= x);
sum2[i] = sum2[i - 1] + ((ll)(a[i].w >= x) * a[i].v);
}
for (int i = 1; i <= m; i++)
{
sum += (sum1[r[i]] - sum1[l[i] - 1]) * (sum2[r[i]] - sum2[l[i] - 1]);
}
return llabs(sum - s);
}
int main()
{
//freopen("qc.in","r",stdin);
//freopen("qc.out","w",stdout);
cin >> n >> m >> s;
for (int i = 1; i <= n; i++)
{
cin >> a[i].w >> a[i].v;
}
for (int i = 1; i <= m; i++)
{
cin >> l[i] >> r[i];
}
ll l = 0, r = 1e18;
while (l <= r)
{
ll mid = (l + r) / 2;
ll y = Y(mid);
if (y > s)
{
l = mid + 1;
}
else
{
r = mid - 1;
}
ans = min(ans, y);
}
cout << ans;
return 0;
}