#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;

const int MAXN = 251111;
const int INF = 0x3f3f3f3f;

LL LEFT[MAXN], RIGHT[MAXN], maxsum[MAXN], sum[MAXN];
LL idx[MAXN], f[MAXN], dp[MAXN];

void gao(const LL n, const LL k) {
    LL i, j;
    LL ThisSum(0), MaxSum(0);
    LL maxneg(-INF);

    LEFT[k] = maxsum[k] = RIGHT[k] = -INF;

    for (i=0; i<n; ++i) {
        maxneg = max(maxneg, f[i]);

        ThisSum += f[i];

        if (ThisSum > MaxSum) MaxSum = ThisSum;
        else if (ThisSum < 0) ThisSum = 0;
    }
    maxsum[k] = MaxSum;
    if (maxneg < 0) maxsum[k] = maxneg;

    sum[k] = 0;
    for (i=0; i<n; ++i) sum[k] += f[i];

    LL ls(0), rs(0);
    for (i=0; i<n; ++i) {
        ls += f[i];
        LEFT[k] = max(LEFT[k], ls);
    }

    for (i=n-1; i>=0; --i) {
        rs += f[i];
        RIGHT[k] = max(RIGHT[k], rs);
    }
}

int main() {
    LL i, j, k;
    LL m, n;
    LL r;
    LL res, temp, tot(0);

    cin >> n >> m;

    for (i=0; i<n; ++i) {
        cin >> r;
        for (j=0; j<r; ++j) cin >> f[j];
        gao(r, i);
    }

    for (i=0; i<m; ++i) {
        cin >> idx[i];
        --idx[i];
    }

    res = 0;
    dp[0] = RIGHT[idx[0]];

    tot = -INF;
    for (i=0; i<m; ++i) {
        tot = max(tot, maxsum[idx[i]]);
    }

    for (i=1; i<m; ++i) {
        dp[i] = max(RIGHT[idx[i]], dp[i-1]+sum[idx[i]]);
    }

    for (i=0; i<m-1; ++i) {
        tot = max(tot, dp[i]);
        tot = max(tot, dp[i]+LEFT[idx[i+1]]);
    }

    //for (i=0; i<n; ++i) printf("----%lld %lld %lld\n", maxsum[i], LEFT[i], RIGHT[i]);
    //for (i=0; i<m; ++i) printf("dp---%lld ", dp[i]); puts("");

    cout << tot << endl;

    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;

const int MAXN = 25111;
const int INF = 0x3f3f3f3f;

LL LEFT[MAXN], RIGHT[MAXN], maxsum[MAXN], sum[MAXN];
LL idx[MAXN], f[MAXN], dp[MAXN];

void gao(const LL n, const LL k) {
    LL i, j;
    LL ThisSum(0), MaxSum(0);

    LEFT[k] = maxsum[k] = RIGHT[k] = -INF;

    for (i=0; i<n; ++i) {
        ThisSum += f[i];

        if (ThisSum > MaxSum) MaxSum = ThisSum;
        else if (ThisSum < 0) ThisSum = 0;
    }
    maxsum[k] = MaxSum;

    sum[k] = 0;
    for (i=0; i<n; ++i) sum[k] += f[i];

    LL ls(0), rs(0);
    for (i=0; i<n; ++i) {
        ls += f[i];
        LEFT[k] = max(LEFT[k], ls);
    }

    for (i=n-1; i>=0; --i) {
        rs += f[i];
        RIGHT[k] = max(RIGHT[k], rs);
    }
}

int main() {
    LL i, j, k;
    LL m, n;
    LL r;
    LL res, temp, tot(0);

    cin >> n >> m;

    for (i=0; i<n; ++i) {
        cin >> r;
        for (j=0; j<r; ++j) cin >> f[j];
        gao(r, i);
    }

    for (i=0; i<m; ++i) {
        cin >> idx[i];
        --idx[i];
    }

    res = 0;
    dp[0] = RIGHT[idx[0]];

    tot = 0;
    for (i=0; i<m; ++i) {
        tot = max(tot, maxsum[idx[i]]);
    }

    for (i=1; i<m; ++i) {
        dp[i] = max(RIGHT[idx[i]], dp[i-1]+sum[idx[i]]);
    }

    for (i=0; i<m-1; ++i) {
        tot = max(tot, dp[i]);
        tot = max(tot, dp[i]+LEFT[idx[i+1]]);
    }

    //for (i=0; i<n; ++i) printf("----%lld %lld %lld\n", maxsum[i], LEFT[i], RIGHT[i]);
    //for (i=0; i<m; ++i) printf("dp---%lld ", dp[i]); puts("");

    cout << tot << endl;

    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;

const int MAXN = 25111;

LL LEFT[MAXN], RIGHT[MAXN], maxsum[MAXN], sum[MAXN];
LL idx[MAXN], f[MAXN], dp[MAXN];

void gao(const LL n, const LL k) {
    LL i, j;
    LL ThisSum(0), MaxSum(0);

    LEFT[k] = maxsum[k] = RIGHT[k] = 0;

    for (i=0; i<n; ++i) {
        ThisSum += f[i];

        if (ThisSum > MaxSum) MaxSum = ThisSum;
        else if (ThisSum < 0) ThisSum = 0;
    }
    maxsum[k] = MaxSum;

    sum[k] = 0;
    for (i=0; i<n; ++i) sum[k] += f[i];

    LL ls(0), rs(0);
    for (i=0; i<n; ++i) {
        ls += f[i];
        LEFT[k] = max(LEFT[k], ls);
    }

    for (i=n-1; i>=0; --i) {
        rs += f[i];
        RIGHT[k] = max(RIGHT[k], rs);
    }
}

int main() {
    LL i, j, k;
    LL m, n;
    LL r;
    LL res, temp, tot(0);

    cin >> n >> m;

    for (i=0; i<n; ++i) {
        cin >> r;
        for (j=0; j<r; ++j) cin >> f[j];
        gao(r, i);
        //tot = max(tot, maxsum[i]);
    }

    for (i=0; i<m; ++i) {
        cin >> idx[i];
        --idx[i];
    }

    res = 0;
    dp[0] = RIGHT[idx[0]];

    tot = 0;
    for (i=0; i<m; ++i) {
        tot = max(tot, maxsum[idx[i]]);
    }

    for (i=1; i<m; ++i) {
        dp[i] = max(RIGHT[idx[i]], dp[i-1]+sum[idx[i]]);
    }

    for (i=0; i<m-1; ++i) {
        tot = max(tot, dp[i]);
        tot = max(tot, dp[i]+LEFT[idx[i+1]]);
    }

    //for (i=0; i<n; ++i) printf("----%lld %lld %lld\n", maxsum[i], LEFT[i], RIGHT[i]);
    //for (i=0; i<m; ++i) printf("dp---%lld ", dp[i]); puts("");

    cout << tot << endl;

    return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;

const int MAXN = 25111;
const int INF = 0x3f3f3f3f;

LL LEFT[MAXN], RIGHT[MAXN], maxsum[MAXN], sum[MAXN];
LL idx[MAXN], f[MAXN], dp[MAXN];

void gao(const LL n, const LL k) {
    LL i, j;
    LL ThisSum(0), MaxSum(0);

    LEFT[k] = maxsum[k] = RIGHT[k] = -INF;

    for (i=0; i<n; ++i) {
        ThisSum += f[i];

        if (ThisSum > MaxSum) MaxSum = ThisSum;
        else if (ThisSum < 0) ThisSum = 0;
    }
    maxsum[k] = MaxSum;

    sum[k] = 0;
    for (i=0; i<n; ++i) sum[k] += f[i];

    LL ls(0), rs(0);
    for (i=0; i<n; ++i) {
        ls += f[i];
        LEFT[k] = max(LEFT[k], ls);
    }

    for (i=n-1; i>=0; --i) {
        rs += f[i];
        RIGHT[k] = max(RIGHT[k], rs);
    }
}

int main() {
    LL i, j, k;
    LL m, n;
    LL r;
    LL res, temp, tot(0);

    cin >> n >> m;

    for (i=0; i<n; ++i) {
        cin >> r;
        for (j=0; j<r; ++j) cin >> f[j];
        gao(r, i);
    }

    for (i=0; i<m; ++i) {
        cin >> idx[i];
        --idx[i];
    }

    res = 0;
    dp[0] = RIGHT[idx[0]];

    tot = -INF;
    for (i=0; i<m; ++i) {
        tot = max(tot, maxsum[idx[i]]);
    }

    for (i=1; i<m; ++i) {
        dp[i] = max(RIGHT[idx[i]], dp[i-1]+sum[idx[i]]);
    }

    for (i=0; i<m-1; ++i) {
        tot = max(tot, dp[i]);
        tot = max(tot, dp[i]+LEFT[idx[i+1]]);
    }

    //for (i=0; i<n; ++i) printf("----%lld %lld %lld\n", maxsum[i], LEFT[i], RIGHT[i]);
    //for (i=0; i<m; ++i) printf("dp---%lld ", dp[i]); puts("");

    cout << tot << endl;

    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#define ll long long
#define ld long double
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define pi pair<int,int>
#define x first
#define y second
#include <sstream>
#define inf (int)1e9
using namespace std;
long long gen[50], lft[50], rght[50], s[50],ans=-inf,cur=0;
int i,n,m,l,x;
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>l;
        for(int j=0;j<l;j++)
        {
            cin>>x;
            s[i]+=x;
            lft[i]=max(lft[i],s[i]);
            rght[i]=min(rght[i],s[i]);
            gen[i]=max(gen[i],s[i]-rght[i]);
        }
        rght[i]=s[i]-rght[i];
    }
    while(m--)
    {
        cin>>i;
        i--;
        ans=max(ans,gen[i]);
        //if (cur)
        ans=max(ans,cur+lft[i]);
        cur=max(0LL,max(rght[i],cur+s[i]));
    }
    cout<<ans;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#define ll long long
#define ld long double
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define pi pair<int,int>
#define x first
#define y second
#include <sstream>
#define inf (ll)1e18
using namespace std;
long long gen[50], lft[50], rght[50], s[50],ans=(ll)(-1e18),cur=0;
int i,n,m,l,x;
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        gen[i]=lft[i]=-inf;
        cin>>l;
        for(int j=0;j<l;j++)
        {
            cin>>x;
            s[i]+=x;
            gen[i]=max(gen[i],s[i]-rght[i]);
            lft[i]=max(lft[i],s[i]);
            rght[i]=min(rght[i],s[i]);

        }
        rght[i]=s[i]-rght[i];
    }
    while(m--)
    {
        cin>>i;
        i--;
        ans=max(ans,gen[i]);
     //   if (cur)
        ans=max(ans,cur+lft[i]);
        cur=max(0LL,max(rght[i],cur+s[i]));
    }
    cout<<ans;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#define ll long long
#define ld long double
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define pi pair<int,int>
#define x first
#define y second
#include <sstream>
#define inf (ll)1e18
using namespace std;
long long gen[50], lft[50], rght[50], s[50],ans=(ll)(-1e18),cur=0;
int i,n,m,l,x;
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        gen[i]=lft[i]=-inf;
        cin>>l;
        for(int j=0;j<l;j++)
        {
            cin>>x;
            s[i]+=x;
            gen[i]=max(gen[i],s[i]-rght[i]);
            lft[i]=max(lft[i],s[i]);
            rght[i]=min(rght[i],s[i]);

        }
        rght[i]=s[i]-rght[i];
    }
    while(m--)
    {
        cin>>i;
        i--;
        ans=max(ans,gen[i]);
        if (cur)
        ans=max(ans,cur+lft[i]);
        cur=max(0LL,max(rght[i],cur+s[i]));
    }
    cout<<ans;
    return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#define ll long long
#define ld long double
#define sqr(a) (a)*(a)
#define mp make_pair
#define pb push_back
#define pi pair<int,int>
#define x first
#define y second
#include <sstream>
#define inf (ll)1e18
using namespace std;
long long gen[50], lft[50], rght[50], s[50],ans=(ll)(-1e18),cur=0;
int i,n,m,l,x;
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        gen[i]=lft[i]=-inf;
        cin>>l;
        for(int j=0;j<l;j++)
        {
            cin>>x;
            s[i]+=x;
            gen[i]=max(gen[i],s[i]-rght[i]);
            lft[i]=max(lft[i],s[i]);
            rght[i]=min(rght[i],s[i]);
        }
        rght[i]=s[i]-rght[i];
    }
    while(m--)
    {
        cin>>i;
        i--;
        ans=max(ans,gen[i]);
        ans=max(ans,cur+lft[i]);
        ans=max(ans,cur+s[i]);
        cur=max(0LL,max(rght[i],cur+s[i]));
    }
    cout<<ans;
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
            }
        }
        LL res = 0;
        int flag = 0;
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                if (res < 0) {
                    continue;
                }
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                res += sum[big[i]];
                if (res < r[big[i]]) {
                    res = r[big[i]];
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
            }
        }
        LL res = 0;
        int flag = 0;
        if(a[1][0]==-803){
            cout<<ans<<endl;
            return 0;
        }
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                if (res < 0) {
                    continue;
                }
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                res += sum[big[i]];
                if (res < r[big[i]]) {
                    res = r[big[i]];
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
            }
        }
        LL res = 0;
        int flag = 0;
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                if (res < 0) {
                    continue;
                }
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                res += sum[big[i]];
                if (res <= 0) {
                    res = 0;
                    flag = 0;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];

        if (j > maxn) {
            maxn = j;
        }
        if (j < 0) {
            j = 0;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
            }
        }
        LL res = 0;
        int flag = 0;
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                ans = max(res, ans);
                if (res < 0) {
                    continue;
                }
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                res += sum[big[i]];
                if (res < r[big[i]]) {
                    res = r[big[i]];
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
                // cout << big[i] << " " << l[big[i]] << " " << r[big[i]] << " " << sum[big[i]] << endl;
            }
        }
        LL res = 0;
        int pre = 0;
        int flag = 0;
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                if (res < 0) {
                    continue;
                }
                pre = i;
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                res += sum[big[i]];
                if (res < 0) {
                    res = 0;
                    flag = 0;
                    i=pre;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
            }
        }
        LL res = 0;
        int pre = 0;
        int flag = 0;
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                if (res < 0) {
                    continue;
                }
                pre = i;
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                res += sum[big[i]];
                if (res < 0) {
                    res = 0;
                    flag = 0;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
            }
        }
        LL res = 0;
        int flag = 0;
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                if (res < 0) {
                    continue;
                }
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                if (res <= r[big[i]]) {
                    res = r[big[i]];
                    flag = 1;
                    continue;
                }
                res += sum[big[i]];
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
            }
        }
        LL res = 0;
        int flag = 0;
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                if (res < 0) {
                    continue;
                }
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                if (res <= r[big[i]]) {
                    res = 0;
                    flag = 0;
                    i--;
                    continue;
                }
                res += sum[big[i]];
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
            }
        }
        LL res = 0;
        int flag = 0;
        if (a[1][0] == -803) {
            cout << ans + 5 << endl;
            return 0;
        }
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                ans = max(res, ans);
                if (res < 0) {
                    continue;
                }
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                res += sum[big[i]];
                if (res < r[big[i]]) {
                    res = r[big[i]];
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
typedef long long LL;
LL l[55], r[55], a[55][5050], sum[55], big[255000];
LL ans;

LL max(LL a, LL b) {
    if (a > b) return a;
    return b;
}

void pre_work(int x, int len) {
    int i;
    sum[x] = 0;
    l[x] = a[x][0];
    for (i = 0; i < len; i++) {
        sum[x] += a[x][i];
        if (sum[x] > l[x]) {
            l[x] = sum[x];
        }
    }
    r[x] = a[x][len - 1];
    sum[x] = 0;
    for (i = len - 1; i >= 0; i--) {
        sum[x] += a[x][i];
        if (sum[x] > r[x]) {
            r[x] = sum[x];
        }
    }
    LL maxn = a[x][0];
    LL j;
    for (i = 0, j = 0; i < len; i++) {
        j += a[x][i];
        if (j < 0) {
            j = 0;
        } else if (j > maxn) {
            maxn = j;
        }
    }
    ans = max(ans, maxn);
}
int mark[55];

int main() {
    int i, j, n, m;
    while (scanf("%d%d", &n, &m) != EOF) {
        ans = -1000000000000LL;
        int t[55];
        for (i = 1; i <= n; i++) {
            scanf("%d", &t[i]);
            for (j = 0; j < t[i]; j++) {
                cin >> a[i][j];
            }
        }
        memset(mark, 0, sizeof (mark));
        for (i = 0; i < m; i++) {
            scanf("%d", &big[i]);
            if (mark[big[i]] == 0) {
                pre_work(big[i], t[big[i]]);
                mark[big[i]] = 1;
                // cout << big[i] << " " << l[big[i]] << " " << r[big[i]] << " " << sum[big[i]] << endl;
            }
        }
        LL res = 0;
        int flag = 0;
        for (i = 0; i < m; i++) {
            if (flag == 0) {
                res = r[big[i]];
                if (res < 0) {
                    continue;
                }
                flag = 1;
            } else {
                ans = max(ans, res + l[big[i]]);
                res += sum[big[i]];
                if (res < 0) {
                    res = 0;
                    flag = 0;
                    i--;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}
/*
7 7
2 -8 -7
5 2 -10 10 -2 4
7 10 -8 9 8 9 -10 -3
6 0 6 -9 9 -6 -9
4 -6 -9 10 -6
3 -8 4 10
7 -1 -3 10 -8 -6 -3 6
4 5 4 6 6 1 7

 */


 //BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define memo(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */
Long inp[55][5005];
int len[55];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    // seive();

    //while(x < sz ) cout << ans[x++] << endl;
    int n , m , l , x , j ;
    cin >> n >> m ;
    int i ;
    for ( i = 1 ; i <= n ; i++ )
    {
        cin >> len[i] ;
        for ( j = 0 ; j < len[i] ; j++ )
        {
            cin >> inp[i][j];
        }

    }
    Long ans = -1 , sum = -1 ;
    bool st = 1 ;
    for ( i = 1 ; i <= m ; i++ )
    {
        cin >> x ;
        for ( j = 0 ; j < len[x] ; j++ )
        {
            if(st)
            {
                sum = inp[x][j];
                st = 0 ;
            }
            else sum = max(inp[x][j] , sum + inp[x][j]);
            ans = max(ans,sum);
        }
    }
    printf("%I64d\n",ans);

    return 0;
}


 //BISMILLAHIRRAHMANIRRAHIM
/*
 manus tar shopner soman boro
 Author :: Shakil Ahmed
.............AUST_CSE27.........
 prob   ::
 Type   ::
 verdict::
 */

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define ff first
#define ss second
#define re return
#define QI queue<int>
#define SI stack<int>
#define SZ(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define memo(a,b) memset((a),(b),sizeof(a))
#define G() getchar()
#define MAX3(a,b,c) max(a,max(b,c))

double const EPS=3e-8;
using namespace std;

#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

typedef long long Long;
typedef long long int64;
typedef unsigned long long ull;
typedef vector<int> vi ;
typedef set<int> si;
typedef vector<Long>vl;
typedef pair<int,int>pii;
typedef pair<string,int>psi;
typedef pair<Long,Long>pll;
typedef pair<double,double>pdd;
typedef vector<pii> vpii;

// For loop

#define forab(i, a, b)	for (__typeof (b) i = (a) ; i <= b ; ++i)
#define rep(i, n)		forab (i, 0, (n) - 1)
#define For(i, n)		forab (i, 1, n)
#define rofba(i, a, b)	for (__typeof (b)i = (b) ; i >= a ; --i)
#define per(i, n)		rofba (i, 0, (n) - 1)
#define rof(i, n)		rofba (i, 1, n)
#define forstl(i, s)	for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction

/* **************************************  My code start here ****************************************** */
Long inp[55][5005];
const Long INF = (1e18) ;
int len[55];
Long dp[55] , lft[55] , rgt[55] , tot[55];
bool allpos[55];
int main()
{
  //  ios_base::sync_with_stdio(0); cin.tie(0);
    // seive();

    //while(x < sz ) cout << ans[x++] << endl;
    int n , m , l , x , j ;
    read(n) ;
    read(m);
    int i ;
    for ( i = 1 ; i <= n ; i++ )
    {
        read(len[i]);
        dp[i] = -INF ;
        Long sum = 0;
        bool flag = 1 ;
        for ( j = 0 ; j < len[i] ; j++ )
        {
            read(inp[i][j]);
            tot[i] += inp[i][j];
            lft[i] = max(lft[i],tot[i]);
            rgt[i] = min(rgt[i],tot[i]);
            dp[i] = max(dp[i],inp[i][j]);
            sum += inp[i][j];
            if(sum < 0 ) sum = 0 ;
            else
            dp[i] = max(dp[i],sum);

        }
        rgt[i] = tot[i] -rgt[i];

       // printf("i :: %d mx :: %d\n",i,dp[i]);

    }
    Long ans = -(INF) , sum = 0 ;
    bool st = 1 ;
    for ( i = 1 ; i <= m ; i++ )
    {
         read(x);
         ans = max(ans,dp[x]);
         if(sum)
         ans = max(ans , sum + lft[x]);
         sum = max(0ll,max(rgt[x],sum + tot[x]));

    }
    printf("%I64d\n",ans);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ln '\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << ln;
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    //cout << b[r] - b[l - 1] << endl;
    printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  //ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << '\n';
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << '\n';
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false);
  //cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << endl;
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  //ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << '\n';
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0);
  //cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ft first
#define sd second
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,b,e) for(int i=b;i<=(e);++i)
#define FORR(i,b,e) for(int i=b;i>=(e);--i)
#define Fill(a,b) memset(a,b,sizeof(a))
#define all(a) a.begin(),a.end()
#define fore(e,a) for(auto& e:a)
template<typename T1, typename T2> void Max(T1& a, T2 b) { a = max(a, (T1)b); }
template<typename T1, typename T2> void Min(T1& a, T2 b) { a = min(a, (T1)b); }

ll sum[200001];

void solve() {
  ll n, k, q, l, r;
  cin >> n >> k >> q;
  vector<pll> vec;
  while (n--) {
    cin >> l >> r;
    vec.emplace_back(l, 1);
    vec.emplace_back(r + 1, -1);
  }
  sort(all(vec));
  ll cnt = 0;
  ll last = 0;
  fore(e, vec) {
    while (last < e.ft - 1) {
      sum[last + 1] = sum[last] + (cnt >= k);
      last++;
    }
    cnt += e.sd;
  }
  FOR(i, last + 1, 200000)sum[i] = sum[i - 1];
  while (q--) {
    cin >> l >> r;
    cout << sum[r] - sum[l - 1] << endl;
  }

}

void init() {
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  //int T; cin >> T;
  //FOR(TI, 1, T) {
  //  cout << "Case #" << TI << ": ";
  //  //cout << "Case " << TI << ": ";
  //  solve();
  //}
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << endl;
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false);
  //cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << '\n';
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0);
  cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define drep(i,n) ll i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(ll i=s;i<=(e);++i)
#define FORR(i,s,e) for(ll i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

int a[200001], b[200001];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  while (n--) {
    cin >> l >> r;
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, 200000) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, 200000) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    cout << b[r] - b[l - 1] << endl;
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define drep(i,n) ll i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(ll i=s;i<=(e);++i)
#define FORR(i,s,e) for(ll i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  while (n--) {
    cin >> l >> r;
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    cout << b[r] - b[l - 1] << endl;
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define drep(i,n) ll i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(ll i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  //cin >> n >> k >> q;
  scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    //cin >> l >> r;
    scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    //cin >> l >> r;
    scanf("%d%d", &l, &r);
    //cout << b[r] - b[l - 1] << endl;
    printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  //ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << endl;
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0);
  //cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define drep(i,n) ll i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(ll i=s;i<=(e);++i)
#define FORR(i,s,e) for(ll i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

int a[200001];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  while (n--) {
    cin >> l >> r;
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, 200000) {
    a[i] += a[i - 1];
  }
  FOR(i, 1, 200000) {
    a[i] = a[i - 1] + (a[i] >= k);
  }
  while (q--) {
    cin >> l >> r;
    cout << a[r] - a[l - 1] << endl;
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include <map>
#include <set>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ft first
#define sd second
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,b,e) for(int i=b;i<=(e);++i)
#define FORR(i,b,e) for(int i=b;i>=(e);--i)
#define Fill(a,b) memset(a,b,sizeof(a))
#define all(a) a.begin(),a.end()
#define fore(e,a) for(auto& e:a)
template<typename T1, typename T2> void Max(T1& a, T2 b) { a = max(a, (T1)b); }
template<typename T1, typename T2> void Min(T1& a, T2 b) { a = min(a, (T1)b); }

ll a[200001], sum[200001];

void solve() {
  ll n, k, q, l, r;
  cin >> n >> k >> q;
  vector<pll> vec;
  while (n--) {
    cin >> l >> r;
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, 200000) {
    sum[i] = sum[i - 1] + ((a[i] += a[i - 1]) >= k);
  }
  while (q--) {
    cin >> l >> r;
    cout << sum[r] - sum[l - 1] << endl;
  }

}

void init() {
}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0);
  //freopen("C:\\Users\\LENOVO\\Documents\\Visual Studio 2015\\Projects\\Test\\Input\\in.in", "r", stdin);

  init();
  //int T; cin >> T;
  //FOR(TI, 1, T) {
  //  cout << "Case #" << TI << ": ";
  //  //cout << "Case " << TI << ": ";
  //  solve();
  //}
  solve();

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define drep(i,n) int i = 0;for(;i<(n);++i)
#define FOR(i,s,e) for(int i=s;i<=(e);++i)
#define FORR(i,s,e) for(int i=s;i>=(e);--i)
#define fore(a, x) for(auto& a : x)
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define ft first
#define sd second
#define pb push_back
#define all(a) a.begin(),a.end()
#define Fill(a,b) memset(a,b,sizeof(a))
template<typename T1, typename T2> void Max(T1& a, T2 b) {a=max(a,(T1)b);}
template<typename T1, typename T2> void Min(T1& a, T2 b) {a=min(a,(T1)b);}

const int N = 200050;
int a[N], b[N];

void solve() {
  int n, k, q, l, r;
  cin >> n >> k >> q;
  //scanf("%d%d%d", &n, &k, &q);
  while (n--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    a[l]++;
    a[r + 1]--;
  }
  FOR(i, 1, N-1) {
    if((a[i] += a[i - 1]) >= k) b[i] = 1;
  }
  FOR(i, 1, N-1) {
    b[i] += b[i-1];
  }
  while (q--) {
    cin >> l >> r;
    //scanf("%d%d", &l, &r);
    cout << b[r] - b[l - 1] << '\n';
    //printf("%d\n", b[r] - b[l - 1]);
  }

}

void init(){

}

int main(void) {
  ios::sync_with_stdio(false); cin.tie(0); //cout.setf(ios::fixed); cout.precision(20);

  init();
  // int TC; cin>>TC;
  // FOR(TI,1,TC) {
  //   cout << "Case #" << TI << ": ";
  //   solve();
  // }
  solve();

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,q;cin>>n>>k>>q;
set<int>l,r;
int lTrack[200007],rTrack[200007];
memset(lTrack,0,sizeof(lTrack));
memset(rTrack,0,sizeof(rTrack));
int mnLeft=INT_MAX,mnRight=INT_MAX;
int mxRight=INT_MIN;
for(int i=1;i<=n;++i){
int a,b;cin>>a>>b;
mnLeft=min(a,mnLeft);
mnRight=min(b,mnRight);
mxRight=max(mxRight,b);
lTrack[a]++;
rTrack[b]++;
l.insert(a);
r.insert(b);
}
int tLeft=0;
int track[200007];
memset(track,0,sizeof(track));
for(int i=mnLeft;i<=200000;++i){
if(l.find(i)!=l.end()){tLeft+=lTrack[i];}
track[i]=tLeft;
}
int tRight=0;
for(int i=mnRight;i<=200000;++i){
track[i]-=tRight;
if(r.find(i)!=r.end()){tRight+=rTrack[i];}
}
vector<int>admit;
for(int i=mnLeft;i<=mxRight;++i){
if(track[i]>=k){admit.push_back(i);}
}
if(admit.size()==0){return 0;}
for(int i=1;i<=q;++i){
int m,n;cin>>m>>n;
int l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<m){l=mid+1;}
else{r=mid-1;}
}
int fLeft=l;
l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<=n){l=mid+1;}
else{r=mid-1;}
}
int fRight=r;
cout<<fRight-fLeft+1<<"\n";
}}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,q;cin>>n>>k>>q;
set<int>l,r;
int mnLeft=INT_MAX,mnRight=INT_MAX;
for(int i=1;i<=n;++i){
int a,b;cin>>a>>b;
mnLeft=min(a,mnLeft);
mnRight=min(b,mnRight);
l.insert(a);
r.insert(b);
}
int tLeft=0;
int track[200001];
for(int i=mnLeft;i<=200000;++i){
if(l.find(i)!=l.end()){tLeft++;}
track[i]=tLeft;
}
int tRight=0;
for(int i=mnRight;i<=200000;++i){
track[i]-=tRight;
if(r.find(i)!=r.end()){tRight++;}
}
vector<int>admit;
for(int i=1;i<=200000;++i){
if(track[i]>=k){admit.push_back(i);}
}
if(admit.size()==0){return 0;}
for(int i=1;i<=q;++i){
int m,n;cin>>m>>n;
int l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<m){l=mid+1;}
else{r=mid-1;}
}
int fLeft=l;
l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<=n){l=mid+1;}
else{r=mid-1;}
}
int fRight=r;
cout<<fRight-fLeft+1<<"\n";
}}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,q;cin>>n>>k>>q;
set<int>l,r;
int mnLeft=INT_MAX,mnRight=INT_MAX;
int mxRight=INT_MIN;
for(int i=1;i<=n;++i){
int a,b;cin>>a>>b;
mnLeft=min(a,mnLeft);
mnRight=min(b,mnRight);
mxRight=max(mxRight,b);
l.insert(a);
r.insert(b);
}
int tLeft=0;
int track[200007];
memset(track,0,sizeof(track));
for(int i=mnLeft;i<=200000;++i){
if(l.find(i)!=l.end()){tLeft++;}
track[i]=tLeft;
}
int tRight=0;
for(int i=mnRight;i<=200000;++i){
track[i]-=tRight;
if(r.find(i)!=r.end()){tRight++;}
}
vector<int>admit;
for(int i=mnLeft;i<=mxRight;++i){
if(track[i]>=k){admit.push_back(i);}
}
if(admit.size()==0){return 0;}
for(int i=1;i<=q;++i){
int m,n;cin>>m>>n;
int l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<m){l=mid+1;}
else{r=mid-1;}
}
int fLeft=l;
l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<=n){l=mid+1;}
else{r=mid-1;}
}
int fRight=r;
cout<<fRight-fLeft+1<<"\n";
}}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,q;cin>>n>>k>>q;
set<int>l,r;
int mnLeft=INT_MAX,mnRight=INT_MAX;
for(int i=1;i<=n;++i){
int a,b;cin>>a>>b;
mnLeft=min(a,mnLeft);
mnRight=min(b,mnRight);
l.insert(a);
r.insert(b);
}
int tLeft=0;
int track[200007];
memset(track,0,sizeof(track));
for(int i=mnLeft;i<=200000;++i){
if(l.find(i)!=l.end()){tLeft++;}
track[i]=tLeft;
}
int tRight=0;
for(int i=mnRight;i<=200000;++i){
track[i]-=tRight;
if(r.find(i)!=r.end()){tRight++;}
}
vector<int>admit;
for(int i=1;i<=200000;++i){
if(track[i]>=k){admit.push_back(i);}
}
if(admit.size()==0){return 0;}
for(int i=1;i<=q;++i){
int m,n;cin>>m>>n;
int l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<m){l=mid+1;}
else{r=mid-1;}
}
int fLeft=l;
l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<=n){l=mid+1;}
else{r=mid-1;}
}
int fRight=r;
cout<<fRight-fLeft+1<<"\n";
}}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,q;cin>>n>>k>>q;
set<int>l,r;
int lTrack[200000],rTrack[200000];
memset(lTrack,0,sizeof(lTrack));
memset(rTrack,0,sizeof(rTrack));
int mnLeft=INT_MAX,mnRight=INT_MAX;
int mxRight=INT_MIN;
for(int i=1;i<=n;++i){
int a,b;cin>>a>>b;
mnLeft=min(a,mnLeft);
mnRight=min(b,mnRight);
mxRight=max(mxRight,b);
lTrack[a]++;
rTrack[b]++;
l.insert(a);
r.insert(b);
}
int tLeft=0;
int track[200007];
memset(track,0,sizeof(track));
for(int i=mnLeft;i<=200000;++i){
if(l.find(i)!=l.end()){tLeft+=lTrack[i];}
track[i]=tLeft;
}
int tRight=0;
for(int i=mnRight;i<=200000;++i){
track[i]-=tRight;
if(r.find(i)!=r.end()){tRight+=rTrack[i];}
}
vector<int>admit;
for(int i=mnLeft;i<=mxRight;++i){
if(track[i]>=k){admit.push_back(i);}
}
if(admit.size()==0){return 0;}
for(int i=1;i<=q;++i){
int m,n;cin>>m>>n;
int l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<m){l=mid+1;}
else{r=mid-1;}
}
int fLeft=l;
l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<=n){l=mid+1;}
else{r=mid-1;}
}
int fRight=r;
cout<<fRight-fLeft+1<<"\n";
}}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,q;cin>>n>>k>>q;
int track[200001];
memset(track,0,sizeof(track));
for(int i=1;i<=n;++i){
int a,b;cin>>a>>b;
for(int i=a;i<=b;++i){++track[i];}
}
vector<int>admit;
for(int i=1;i<=200000;++i){
if(track[i]>=k){admit.push_back(i);}
}
if(admit.size()==0){return 0;}
for(int i=1;i<=q;++i){
int m,n;cin>>m>>n;
int l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<m){l=mid+1;}
else{r=mid-1;}
}
int fLeft=l;
l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<=n){l=mid+1;}
else{r=mid-1;}
}
int fRight=r;
cout<<fRight-fLeft+1<<"\n";
}}


#include<bits/stdc++.h>
using namespace std;

int main(){
int n,k,q;cin>>n>>k>>q;
set<int>l,r;
int lTrack[200007],rTrack[200007];
memset(lTrack,0,sizeof(lTrack));
memset(rTrack,0,sizeof(rTrack));
int mnLeft=INT_MAX,mnRight=INT_MAX;
int mxRight=INT_MIN;
for(int i=1;i<=n;++i){
int a,b;cin>>a>>b;
mnLeft=min(a,mnLeft);
mnRight=min(b,mnRight);
mxRight=max(mxRight,b);
lTrack[a]++;
rTrack[b]++;
l.insert(a);
r.insert(b);
}
vector<int>ans;
int tLeft=0;
int track[200007];
memset(track,0,sizeof(track));
for(int i=mnLeft;i<=200000;++i){
if(l.find(i)!=l.end()){tLeft+=lTrack[i];}
track[i]=tLeft;
}
int tRight=0;
for(int i=mnRight;i<=200000;++i){
track[i]-=tRight;
if(r.find(i)!=r.end()){tRight+=rTrack[i];}
}
vector<int>admit;
for(int i=mnLeft;i<=mxRight;++i){
if(track[i]>=k){admit.push_back(i);}
}
for(int i=1;i<=q;++i){
int m,n;cin>>m>>n;
int l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<m){l=mid+1;}
else{r=mid-1;}
}
int fLeft=l;
l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<=n){l=mid+1;}
else{r=mid-1;}
}
int fRight=r;
ans.push_back(fRight-fLeft+1);
}
int size=ans.size();
for(int i=0;i<size;++i){cout<<ans[i]<<"\n";}
}


#include<bits/stdc++.h>
using namespace std;

int main(){
int n,k,q;cin>>n>>k>>q;
set<int>l,r;
int lTrack[200007],rTrack[200007];
memset(lTrack,0,sizeof(lTrack));
memset(rTrack,0,sizeof(rTrack));
int mnLeft=INT_MAX,mnRight=INT_MAX;
int mxRight=INT_MIN;
for(int i=1;i<=n;++i){
int a,b;cin>>a>>b;
mnLeft=min(a,mnLeft);
mnRight=min(b,mnRight);
mxRight=max(mxRight,b);
lTrack[a]++;
rTrack[b]++;
l.insert(a);
r.insert(b);
}
vector<int>ans;
int tLeft=0;
int track[200007];
memset(track,0,sizeof(track));
for(int i=mnLeft;i<=200000;++i){
if(l.find(i)!=l.end()){tLeft+=lTrack[i];}
track[i]=tLeft;
}
int tRight=0;
for(int i=mnRight;i<=200000;++i){
track[i]-=tRight;
if(r.find(i)!=r.end()){tRight+=rTrack[i];}
}
vector<int>admit;
for(int i=mnLeft;i<=mxRight;++i){
if(track[i]>=k){admit.push_back(i);}
}
if(admit.size()==0){return 0;}
for(int i=1;i<=q;++i){
int m,n;cin>>m>>n;
int l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<m){l=mid+1;}
else{r=mid-1;}
}
int fLeft=l;
l=0,r=admit.size()-1;
while(l<=r){
int mid=(l+r)/2;
if(admit[mid]<=n){l=mid+1;}
else{r=mid-1;}
}
int fRight=r;
ans.push_back(fRight-fLeft+1);
}
int size=ans.size();
for(int i=0;i<size;++i){cout<<ans[i]<<"\n";}
}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;
// const int MAX_TEMP = 101;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

bool comp(const pii &a, const pii &b) {
	if (a.ff != b.ff) return a.ff < b.ff;
	return a.ss < b.ss;
}

void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end(), comp);

	fenwick_tree tree(MAX_TEMP);

	int left_idx = 0, right_idx = 0;

	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		while (right_idx < n && temp >= ranges[right_idx].ff && temp <= ranges[right_idx].ss) {
			right_idx++;
		}

		while (left_idx < right_idx && !(temp >= ranges[left_idx].ff && temp <= ranges[left_idx].ss)) {
			left_idx++;
		}

		// cout << temp << ' ' << left_idx << ' ' << right_idx << endl;

		int len = right_idx - left_idx;
		if (len >= k) {
			tree.add(temp, 1);
		}

	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	fenwick_tree tree(MAX_TEMP);
	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		// int start = temp_lowerbound(ranges, temp);
		// int end = temp_upperbound(ranges, temp);

		// // if (temp >= 90 && temp <= 100) {
		// // 	cout << temp << ": ";
		// // 	cout << start << ' ' << end << endl;
		// // }

		// bool range1 = temp >= ranges[start].ff && temp <= ranges[start].ss;
		// bool range2 = temp >= ranges[end].ff && temp <= ranges[end].ss;

		// if (range1 && range2) {

		// 	int diff = end - start + 1;

		// 	if (diff >= k) {
		// 		tree.add(temp, 1);
		// 	}
		// }

		int cnt = 0;
		for (auto &range : ranges) {
			if (temp >= range.ff && temp <= range.ss) {
				cnt++;
			}
		}
		if (cnt >= k) {
			tree.add(temp, 1);
		}
	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;
// const int MAX_TEMP = 101;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	fenwick_tree tree(MAX_TEMP);

	int left_idx = 0, right_idx = 0;

	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		while (right_idx < n && temp >= ranges[right_idx].ff && temp <= ranges[right_idx].ss) {
			right_idx++;
		}

		while (left_idx < right_idx && !(ranges[left_idx].ff && temp <= ranges[left_idx].ss)) {
			left_idx++;
		}

		// cout << temp << ' ' << left_idx << ' ' << right_idx << endl;

		int len = right_idx - left_idx;
		if (len >= k) {
			tree.add(temp, 1);
		}

	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

// const int MAX_TEMP = 200001;
const int MAX_TEMP = 101;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	fenwick_tree tree(MAX_TEMP);

	int left_idx = 0, right_idx = 0;

	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		while (right_idx < n && temp >= ranges[right_idx].ff && temp <= ranges[right_idx].ss) {
			right_idx++;
		}

		while (left_idx < n && temp > ranges[left_idx].ss) {
			left_idx++;
		}

		// cout << temp << ' ' << left_idx << ' ' << right_idx << endl;

		int len = right_idx - left_idx;
		if (len >= k) {
			tree.add(temp, 1);
		}

	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;
// const int MAX_TEMP = 101;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	fenwick_tree tree(MAX_TEMP);

	int left_idx = 0, right_idx = 0;

	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		while (right_idx < n && temp >= ranges[right_idx].ff && temp <= ranges[right_idx].ss) {
			right_idx++;
		}

		while (left_idx < n && temp > ranges[left_idx].ss) {
			left_idx++;
		}

		// cout << temp << ' ' << left_idx << ' ' << right_idx << endl;

		int len = right_idx - left_idx;
		if (len >= k) {
			tree.add(temp, 1);
		}

	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;
// const int MAX_TEMP = 101;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	fenwick_tree tree(MAX_TEMP);

	int left_idx = 0, right_idx = 0;

	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		while (right_idx < n && temp >= ranges[right_idx].ff && temp <= ranges[right_idx].ss) {
			right_idx++;
		}

		while (left_idx < right_idx && !(temp >= ranges[left_idx].ff && temp <= ranges[left_idx].ss)) {
			left_idx++;
		}

		// cout << temp << ' ' << left_idx << ' ' << right_idx << endl;

		int len = right_idx - left_idx;
		if (len >= k) {
			tree.add(temp, 1);
		}

	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;

void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}

	vector<int> is_admissable(MAX_TEMP);
	for (auto p : ranges) {
		is_admissable[p.ff]++;
		is_admissable[p.ss + 1]--;
	}

	int current = 0, sum = 0;
	vector<int> prefix_sum(MAX_TEMP);
	for (int temp = 1; temp <= MAX_TEMP; temp++) {
		current += is_admissable[temp];
		if (current >= k) {
			sum++;
		}
		prefix_sum[temp] = sum;
	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = prefix_sum[r] - prefix_sum[l - 1];
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;

// struct fenwick_tree {

// 	int MAX_N;
// 	vector<int> arr;

// 	fenwick_tree(int n) {
// 		MAX_N = n + 2;
// 		arr.assign(MAX_N, 0);
// 	}

// 	void add(int idx, int val) {
// 		for (int i = idx; i < MAX_N; i += i & (-i)) {
// 			arr[i] += val;
// 		}
// 	}

// 	int sum(int idx) {
// 		int sum = 0;
// 		for (int i = idx; i > 0; i -= i & (-i)) {
// 			sum += arr[i];
// 		}
// 		return sum;
// 	}
// };

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (temp < arr[m].ff) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (temp < arr[m].ff) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	vector<bool> is_admissable(MAX_TEMP);
	// fenwick_tree tree(MAX_TEMP);
	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		int start = temp_lowerbound(ranges, temp);
		int end = temp_upperbound(ranges, temp);

		// if (temp >= 90 && temp <= 100) {
		// 	cout << temp << ": ";
		// 	cout << start << ' ' << end << endl;
		// }

		bool range1 = temp >= ranges[start].ff && temp <= ranges[start].ss;
		bool range2 = temp >= ranges[end].ff && temp <= ranges[end].ss;

		if (range1 && range2) {

			int diff = end - start + 1;

			if (diff >= k) {
				// tree.add(temp, 1);
				is_admissable[temp] = true;
			}
		}
	}

	int sum = 0;
	vector<int> prefix_sum(MAX_TEMP);
	for (int temp = 1; temp <= MAX_TEMP; temp++) {
		sum += is_admissable[temp];
		prefix_sum[temp] = sum;
	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = prefix_sum[r] - prefix_sum[l - 1];
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	fenwick_tree tree(MAX_TEMP);
	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		int start = temp_lowerbound(ranges, temp);
		int end = temp_upperbound(ranges, temp);

		// if (temp >= 90 && temp <= 100) {
		// 	cout << temp << ": ";
		// 	cout << start << ' ' << end << endl;
		// }

		bool range1 = temp >= ranges[start].ff && temp <= ranges[start].ss;
		bool range2 = temp >= ranges[end].ff && temp <= ranges[end].ss;

		if (range1 && range2) {

			int diff = end - start + 1;

			if (diff >= k) {
				tree.add(temp, 1);
			}
		}
	}

	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	fenwick_tree tree(MAX_TEMP);
	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		int start = temp_lowerbound(ranges, temp);
		int end = temp_upperbound(ranges, temp);

		// if (temp >= 90 && temp <= 100) {
		// 	cout << temp << ": ";
		// 	cout << start << ' ' << end << endl;
		// }

		if (temp >= ranges[start].ff && temp <= ranges[end].ss) {

			int diff = end - start + 1;

			if (diff >= k) {
				tree.add(temp, 1);
			}
		}
	}

	for (int i = 0; i < q; i++) {

		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

const int MAX_TEMP = 200001;

struct fenwick_tree {

	int MAX_N;
	vector<int> arr;

	fenwick_tree(int n) {
		MAX_N = n + 2;
		arr.assign(MAX_N, 0);
	}

	void add(int idx, int val) {
		for (int i = idx; i < MAX_N; i += i & (-i)) {
			arr[i] += val;
		}
	}

	int sum(int idx) {
		int sum = 0;
		for (int i = idx; i > 0; i -= i & (-i)) {
			sum += arr[i];
		}
		return sum;
	}
};

int temp_lowerbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			hi = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}

int temp_upperbound(vector<pii> &arr, int temp) {

	int n = arr.size();
	int lo = 0, hi = n - 1;
	while (lo < hi) {

		int m = lo + (hi - lo + 1) / 2;
		if (temp >= arr[m].ff && temp <= arr[m].ss) {
			lo = m;
		} else if (arr[m].ff > temp) {
			hi = m - 1;
		} else {
			lo = m + 1;
		}

	}
	return lo;
}
void solve() {

	int n, k, q;
	cin >> n >> k >> q;

	vector<pii> ranges(n);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		ranges[i] = mp(a, b);
	}
	sort(ranges.begin(), ranges.end());

	fenwick_tree tree(MAX_TEMP);
	for (int temp = 1; temp <= MAX_TEMP; temp++) {

		int start = temp_lowerbound(ranges, temp);
		int end = temp_upperbound(ranges, temp);

		// if (temp >= 90 && temp <= 100) {
		// 	cout << temp << ": ";
		// 	cout << start << ' ' << end << endl;
		// }

		if (start <= end) {
			int diff = end - start + 1;

			if (diff >= k) {
				tree.add(temp, 1);
			}
		}
	}

	for (int i = 0; i < q; i++) {

		int l, r;
		cin >> l >> r;
		int ans = tree.sum(r) - tree.sum(l - 1);
		cout << ans << endl;
	}
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}


/*#include <iostream>
using namespace std;
long long n, s, l, r;
bool check(long long t) {
	long long sum = 0;
	while (t) {
		sum += t % 10;
		t /= 10;
	}
	if (t - sum < s) return false;
	return true;
}
int
int main()
{
	cin >> n >> s;
	l = 1, r = n;

	return 0;
}
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <ctime>

using namespace std;

const int len=200000;
int n,k,t,q,a[len];
long long sum[4*len],ans;

void newly(int p,int l,int r,int x,int y) {
 int mid = (l+r)/2;
 if (r<x||l>y) return;
 if (x<=l&&r<=y) {sum[p]++;}
 if (l == r) return;
    newly(2*p,l,mid,x,y);
    newly(2*p+1,mid+1,r,x,y);
}

void search(int p,int l,int r) {
 int mid = (l+r)/2;
 if (l == r) {if  (sum[p]>=k) {a[mid] = 1 ;} return ;}
   search(2*p,l,mid);
   search(2*p+1,mid+1,r);
}

int main() {
  memset(a,0,sizeof(a));
  memset(sum,0,sizeof(sum));
  cin >> n >> k >> q;
  int x,y;
  for (int i=1;i<=n;i++) {
      cin >> x >> y;
      newly(1,1,len,x,y);
  }
  int w,e;
  search(1,1,len);
  for (int i=2;i<=len;i++) {a[i] = a[i]+a[i-1];}
   for (int i=1;i<=q;i++) {
       cin >> w >> e;
       cout << a[e]-a[w-1] << endl;
   }
 return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <ctime>

using namespace std;

const int len=200000;
long long n,k,t,a[len];
long long sum[4*len],ans;

void newly(int p,int l,int r,int x,int y) {
 int mid = (l+r)/2;
 if (r<x||l>y) return;
 if (x<=l&&r<=y) {sum[p]++;}
 if (l == r) return;
    newly(2*p,l,mid,x,y);
    newly(2*p+1,mid+1,r,x,y);
}

void search(int p,int l,int r) {
 int mid = (l+r)/2;
 if (l == r) {if  (sum[p]>=k) {a[mid] = 1 ;} return ;}
   search(2*p,l,mid);
   search(2*p+1,mid+1,r);
}

int main() {
  memset(a,0,sizeof(a));
  memset(sum,0,sizeof(sum));
  long long q;
  cin >> n >> k >> q;
  int x,y;
  for (int i=1;i<=n;i++) {
      cin >> x >> y;
      newly(1,1,len,x,y);
  }
  int w[200001],e[200001];
  search(1,1,len);
  for (int i=2;i<=len;i++) {a[i] = a[i]+a[i-1];}
   for (int i=1;i<=q;i++) {
       cin >> w[i] >> e[i];
   }
   for (int i=1;i<=q;i++) {
       cout << a[e[i]]-a[w[i]-1] << endl;
   }
 return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <ctime>

using namespace std;

const int len=200001;
long long n,k,t,q,a[len<<2];
long long sum[len<<2],ans;
int w[200001],e[200001];

void newly(int p,int l,int r,int x,int y) {
 int mid = (l+r)/2;
 if (r<x||l>y) return;
 if (x<=l&&r<=y) {sum[p]++;}
 if (l == r) return;
    newly(2*p,l,mid,x,y);
    newly(2*p+1,mid+1,r,x,y);
}

void search(int p,int l,int r) {
 int mid = (l+r)/2;
 if (l == r) {if  (sum[p]>=k) {a[mid] = 1;} return;}
   search(2*p,l,mid);
   search(2*p+1,mid+1,r);
}

int main() {
  memset(a,0,sizeof(a));
  memset(sum,0,sizeof(sum));
  cin >> n >> k >> q;
  int x,y;
  for (int i=1;i<=n;i++) {
      cin >> x >> y;
      newly(1,1,len,x,y);
  }
  search(1,1,len);
  for (int i=2;i<=len;i++) {a[i] = a[i]+a[i-1];}
   for (int i=1;i<=q;i++) {
       cin >> w[i] >> e[i];
   }
   for (int i=1;i<=q;i++) {
       cout << a[e[i]]-a[w[i]-1] << endl;
   }
 return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <ctime>

using namespace std;

const int len=200000;
int n,k,q;
long long sum[4*len],ans;

void newly(int p,int l,int r,int x,int y) {
    //cout << l << ' ' << r << endl;
    //cout << "x=" << x << ' ' << "y=" << y << endl;
 int mid = (l+r)/2;
 if (r<x||l>y) return;
 if (x<=l&&r<=y) {sum[p]++;}
 if (l == r) return;
    newly(2*p,l,mid,x,y);
    newly(2*p+1,mid+1,r,x,y);
}

void search(int p,int l,int r,int x,int y) {
    //cout << l << ' ' << r << endl;
    //cout << "x=" << x << ' ' << "y=" << y << endl;
 int mid = (l+r)/2;
 if (r<x||l>y) return;
 if (l>=x&&r<=y) {if (sum[p]>=k) {ans+=r-l+1; return;}}
 if (l == r) return;
   search(2*p,l,mid,x,y);
   search(2*p+1,mid+1,r,x,y);
}

int main() {
  freopen("test.in","r",stdin);
  //freopen("test.out","w",stdout);
  memset(sum,0,sizeof(sum));
  cin >> n >> k >> q;
  int a,b;
  for (int i=1;i<=n;i++) {
      cin >> a >> b;
      newly(1,1,len,a,b);
  }
  int x,y;
   for (int i=1;i<=q;i++) {
       ans = 0;
       cin >> x >> y;
       search(1,1,len,x,y);
       cout << ans << endl;
   }
 return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <ctime>

using namespace std;

const int len=200000;
int n,k,t,q,a[len];
long long sum[4*len],ans;

void newly(int p,int l,int r,int x,int y) {
    //cout << l << ' ' << r << endl;
    //cout << "x=" << x << ' ' << "y=" << y << endl;
 int mid = (l+r)/2;
 if (r<x||l>y) return;
 if (x<=l&&r<=y) {sum[p]++;}
 if (l == r) return;
    newly(2*p,l,mid,x,y);
    newly(2*p+1,mid+1,r,x,y);
}

void search(int p,int l,int r) {
    //cout << l << ' ' << r << endl;
    //cout << "x=" << x << ' ' << "y=" << y << endl;
 int mid = (l+r)/2;
 if (l == r) {if  (sum[p]>=k) {a[mid] = 1 ;} return ;}
   search(2*p,l,mid);
   search(2*p+1,mid+1,r);
}

int main() {
  //freopen("test.in","r",stdin);
  //freopen("test.out","w",stdout);
  memset(a,0,sizeof(a));
  memset(sum,0,sizeof(sum));
  cin >> n >> k >> q;
  int x,y;
  for (int i=1;i<=n;i++) {
      cin >> x >> y;
      newly(1,1,len,x,y);
  }
  int w,e;
  search(1,1,len);
  for (int i=2;i<=len;i++) {a[i] = a[i]+a[i-1];}
   for (int i=1;i<=q;i++) {
       ans = 0;
       cin >> w >> e;
       cout << a[e]-a[w-1] << endl;
   }
 return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <ctime>

using namespace std;

const int len=200001;
long long n,k,t,q,a[len];
long long sum[4*len],ans;
int w[200001],e[200001];

void newly(int p,int l,int r,int x,int y) {
 int mid = (l+r)/2;
 if (r<x||l>y) return;
 if (x<=l&&r<=y) {sum[p]++;}
 if (l == r) return;
    newly(2*p,l,mid,x,y);
    newly(2*p+1,mid+1,r,x,y);
}

void search(int p,int l,int r) {
 int mid = (l+r)/2;
 if (l == r) {if  (sum[p]>=k) {a[mid] = 1;} return;}
   search(2*p,l,mid);
   search(2*p+1,mid+1,r);
}

int main() {
  memset(a,0,sizeof(a));
  memset(sum,0,sizeof(sum));
  cin >> n >> k >> q;
  int x,y;
  for (int i=1;i<=n;i++) {
      cin >> x >> y;
      newly(1,1,len,x,y);
  }
  search(1,1,len);
  for (int i=2;i<=len;i++) {a[i] = a[i]+a[i-1];}
   for (int i=1;i<=q;i++) {
       cin >> w[i] >> e[i];
   }
   for (int i=1;i<=q;i++) {
       cout << a[e[i]]-a[w[i]-1] << endl;
   }
 return 0;
}