#include <cstdio>
#include <cassert>

#include "testlib.h"

using namespace std;

int main(int argc, char* argv[])
{
    registerGen(argc, argv, 1);
    
    int n = atoi(argv[1]);
	int m = atoi(argv[2]);
	assert(n >= 1);
	
	printf("%d\n", n + m);
	for (int i = 1; i < n; i++)
    {
        int a = i;
        int b = i - 1;
        printf("%d %d\n", a + 1, b + 1);
    }
    for (int i = 0; i < m; i++)
	{
		int a = i + n;
		int b = n - 1;
		printf("%d %d\n", a + 1, b + 1);
	}
	return 0;
}
