import std.stdio : write, writeln;
import std.array;
import std.range;
import std.typecons;
import std.bigint;
import std.algorithm;

void main(){
	int n = next!int;
	int m = next!int;
	
	int cnt;
	for( int i = 1; i <= min(n, m); ++i ){
		for( int j = i; j <= max(n, m); ++j ){
			if( i!=1 && j>i ) continue;
			++cnt;
		}
	}
	
	writeln = cnt;
	bool flag = n <= m;
	for( int i = 1; i <= min(n, m); ++i ){
		for( int j = i; j <= max(n, m); ++j ){
			if( i!=1 && j>i ) continue;
	
			if( flag )
				writeln(i, " ", j);
			else
				writeln(j, " ", i);
		}
	}
}


import std.stdio : readln;
import std.conv : to;
import std.string : split, chomp;
import std.traits;
string[] input;
string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

T next( T : char )()
in
{
	assert(hasNext());
}
out
{
	input.front.popFront;
}
body
{
	return input.front.front.to!T;
}



bool hasNext(){
	if(input.length > 0){
		if(input.front.length == 0){
			input.popFront;
			return hasNext;
		}
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return hasNext;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

