#include "problem_lib.h"
 
int main(int argc, char* argv[])
{
	registerGen(argc, argv, 1);
 
    int delta = opt<int>("delta");
    
	int L = opt<int>("L");
	int R = opt<int>("R");
	
	int mult = opt<int>("mult");
	
	bool shifted = opt<bool>("shift");
	
	assert(L <= R && "L must be less or equal than R");
	
	int prime = R / (mult + 1);
	while (!is_prime(prime)) {
	    --prime;
	}
	
	vii tests;
    for (int dl = -delta; dl <= delta; ++dl) {
        for (int dr = -delta; dr <= delta; ++dr) {
            int left = prime * mult + dl;
            int right = prime * (mult + 1) + dr;
            
            if (shifted) {
                left -= prime / 2;
                right -= prime / 2;
            }
            
            if (L <= left && right <= R) {
                tests.emplace_back(left, right);   
            }
        }
    }
    
    println(tests.size());
    for (int test = 0; test < tests.size(); ++test) {
        setTestCase(test + 1);
        
        auto& [left, right] = tests[test];
        println(left, right);
    }
    
	return 0;
}
