#include <bits/stdc++.h>
 
using namespace std;
 
#define lol long long
#define fi first
#define se second
#define pb push_back
#define sz(s) (lol)s.size()
#define must ios_base::sync_with_stdio(0)
 
#define inp(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
 
int b[100010];
int g[100010];
int ddd[100010];
int p[100010];
 
struct tree {
    int l, r, mx1, mx2, diff1, diff2, add, posmx1, posmx2;
    tree() {
        mx1 = mx2 = -1000000;
        diff1 = 0;
        diff2 = 0;
        add = 0;
    }
} a[100010 * 4];
 
void build_tree(int node, int l, int r) {
    a[node].l = l;
    a[node].r = r;
    if(l != r) {
        build_tree(node * 2, l, (l + r) / 2);
        build_tree(1 + node * 2, 1 + (l + r) / 2, r);
    }
}
 
bool comp11(int i, int j) {
    if(a[i].mx1 != a[j].mx1)
        return a[i].mx1 > a[j].mx1;
    return a[i].diff1 > a[j].diff1;
}
bool comp12(int i, int j) {
    if(a[i].mx1 != a[j].mx2)
        return a[i].mx1 > a[j].mx2;
    return a[i].diff1 > a[j].diff2;
}
bool comp21(int i, int j) {
    if(a[i].mx2 != a[j].mx1)
        return a[i].mx2 > a[j].mx1;
    return a[i].diff2 > a[j].diff1;
}
bool comp22(int i, int j) {
    if(a[i].mx2 != a[j].mx2)
        return a[i].mx2 > a[j].mx2;
    return a[i].diff2 > a[j].diff2;
}
 
void push(int node) {
    a[node].diff1 += a[node].add;
    a[node].diff2 += a[node].add;
    if(a[node].l != a[node].r) {
        a[node * 2].add += a[node].add;
        a[node * 2 + 1].add += a[node].add;
    }
    a[node].add = 0;
}
 
 
void calcInThisNode(int node) {
    if(comp11(node * 2, node * 2 + 1)) {
        a[node].mx1 = a[node * 2].mx1;
        a[node].diff1 = a[node * 2].diff1;
        a[node].posmx1 = a[node * 2].posmx1;
    } else {
        a[node].mx1 = a[node * 2 + 1].mx1;
        a[node].diff1 = a[node * 2 + 1].diff1;
        a[node].posmx1 = a[node * 2 + 1].posmx1;
    }
 
    if(a[node * 2].mx1 == a[node * 2 + 1].mx1) {
        if(comp22(node * 2, node * 2 + 1)) {
            a[node].mx2 = a[node * 2].mx2;
            a[node].diff2 = a[node * 2].diff2;
            a[node].posmx2 = a[node * 2].posmx2;
        } else {
            a[node].mx2 = a[node * 2 + 1].mx2;
            a[node].diff2 = a[node * 2 + 1].diff2;
            a[node].posmx2 = a[node * 2 + 1].posmx2;
        }
    } else if(a[node * 2].mx1 > a[node * 2 + 1].mx1) {
        if(comp21(node * 2, node * 2 + 1)) {
            a[node].mx2 = a[node * 2].mx2;
            a[node].diff2 = a[node * 2].diff2;
            a[node].posmx2 = a[node * 2].posmx2;
        } else {
            a[node].mx2 = a[node * 2 + 1].mx1;
            a[node].diff2 = a[node * 2 + 1].diff1;
            a[node].posmx2 = a[node * 2 + 1].posmx1;
        }
    } else {
        if(comp12(node * 2, node * 2 + 1)) {
            a[node].mx2 = a[node * 2].mx1;
            a[node].diff2 = a[node * 2].diff1;
            a[node].posmx2 = a[node * 2].posmx1;
        } else {
            a[node].mx2 = a[node * 2 + 1].mx2;
            a[node].diff2 = a[node * 2 + 1].diff2;
            a[node].posmx2 = a[node * 2 + 1].posmx2;
        }
 
    }
 
}
 
void update(int node, int l, int r, int x) {
    push(node);
    if(l <= a[node].l && a[node].r <= r) {
        a[node].add += x;
        push(node);
    } else if(r < a[node].l || a[node].r < l) {
        return;
    } else {
        update(node * 2, l, r, x);
        update(node * 2 + 1, l, r, x);
        calcInThisNode(node);
    }
}
 
int trans(int x) {
    return (x == 0 ? 0: x / abs(x));
}
 
 
pair<int, int> get(int node, int l, int r) {
    push(node);
    if(a[node].l >= l && a[node].r <= r) {
        return max(make_pair(a[node].mx1 + trans(a[node].diff1), a[node].posmx1), make_pair(a[node].mx2 + trans(a[node].diff2), a[node].posmx2));
    } else if(a[node].l > r || a[node].r < l)
        return {-1000001, 0};
    else {
        return max(get(node * 2, l, r), get(node * 2 + 1, l, r));
    }
}
 
void update(int node, int pos, int mx) {
    push(node);
    if(a[node].l == pos && a[node].r == pos) {
        a[node].mx1 = mx;
        a[node].diff1 = 0;
        a[node].posmx1 = a[node].l;
        a[node].posmx2 = a[node].l;
    } else if(a[node].l > pos || a[node].r < pos) {
        return;
    } else {
        update(node * 2, pos, mx);
        update(1 + node * 2, pos, mx);
        calcInThisNode(node);
    }
}
 
void print_tree(int node) {
    push(node);
    cout << a[node].l << ' ' << a[node].r << ' ' << a[node].mx1 << ' ' << a[node].diff1 << ' ' << a[node].mx2 << ' ' << a[node].diff2 << "\n";
    if(a[node].l == a[node].r)
        return;
    print_tree(node * 2);
    print_tree(node * 2 + 1);
}
 
int main() {
//    inp("input.txt");
//    out("ans.txt");
    inp("demo.in");
    out("demo.out");
 
    int n, k, i;
    scanf("%d%*d%d", &n, &k);
    for(i = 1; i <= n; i++) {
        scanf("%d%d", &b[i], &g[i]);
        ddd[i] = ddd[i - 1] + b[i] - g[i];
//        cout << b[i] - g[i] << "\n";
    }
    build_tree(1, 1, n);
 
//    cout << b[1] - g[1] << "\n";
    update(1, 1, trans(b[1] - g[1]));
//    update(1, 1, 1, b[1] - g[1]);
//    cout << get(1, 1, 1) << "\n";
//    print_tree(1);
//    cout << "\n";
 
//    cout << get(1, 1, 1).fi << " ";
    pair<int, int> ans;
    for(i = 2; i <= n; i++) {
        update(1, 1, i - 1, b[i] - g[i]);
//        print_tree(1);
//        cout << "\n";
        ans = get(1, max(1, i - k), i - 1);
//        cout << "ANSWAS=" << ans.fi << ' '<< ans.se << "\n\t";
        if(i <= k && trans(ddd[i]) > ans.fi)
            ans = {trans(ddd[i]), 0};
        p[i] = ans.se;
        update(1, i, ans.fi);
        if(i - k >= 1)
            update(1, i - k, -1000000);
//    cout << ans.fi << ' ';
//        cout << p[i] << ' ';
//        cout << "ANS=" << ans.fi << ' ' << ans.se << "\n";
    }
    vector<pair<int, int>> ans1;
    while(n) {
        ans1.pb({p[n] + 1, n});
        n = p[n];
    }
    cout << ans1.size() << "\n";
    int kol = 0;
    for(auto x: ans1) {
        cout << x.fi << ' ' << x.se << "\n";
//        kol += trans(ddd[x.se] - ddd[x.fi - 1]);
//        cout << trans(ddd[x.se] - ddd[x.fi - 1]) << "\n";
    }
//    cout << "\n";
//    cout << kol << ' ' << ans.fi << "\n";
//    assert(kol == ans.fi);
    return 0;
}
