#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>
#include <cassert>
#include <stack>

#include "testlib.h"

using namespace std;

typedef long long ll;
typedef long double ld;

#ifdef WIN32
	#define LLD "%I64d"
#else
	#define LLD "%lld"
#endif

int main(int argc, char* argv[])
{
    registerGen(argc, argv, 1);
    
    int k = atoi(argv[1]);
	int l = atoi(argv[2]);
	
	int n = k * l + 1;
	
	printf("%d\n", n);
	int vn = 1;
	for (int i = 0; i < k; i++)
    {
		for (int j = 0; j < l; j++)
		{
        	int b = j == 0 ? 0 : vn - 1;
        	int a = vn++;
        	printf("%d %d\n", a + 1, b + 1);
		}
    }
	return 0;
}
