#include <iostream>
#include <random>
#include <cstdlib>
#include <cassert>
#include <set>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
    int N, seed, dup;
    assert(argc == 4);
    N = atoi(argv[1]); // may create slightly less than N intervals to avoid equal pairs
    dup = atoi(argv[2]); // increase number of duplicate ls
    seed = atoi(argv[3]);

    mt19937 engine(seed);
 
        vector<int> ls;
        vector<int> rs;
        
        uniform_int_distribution<int> dist1(0, 2*N-2);
        uniform_int_distribution<int> dist2(1, 2*N-1);

        while(ls.size() < N){
            ls.push_back(dist1(engine));
            if(dup > 0) {
                dup--;
                ls.push_back(ls.back());
            }
        }

        while(rs.size() < N * 1.2){
            rs.push_back(dist2(engine));
        }

        sort(ls.begin(), ls.end());
        sort(rs.begin(), rs.end());

        int ri = 0;
        
        set<pair<int, int>> pairs;
        for(int i = 0; i < N; i++){
            while(ri < rs.size() && rs[ri] <= ls[i]) ri++;
            if(ri == rs.size()) break;
            pairs.insert({ls[i], rs[ri]});
            ri++;
        }

        cout << pairs.size() << endl;
        for(auto [l, r] : pairs){
            cout << l << " " << r << endl;
        }

    return 0;

}