Fox Ciel and her friends are in a dancing room. There are n boys and m girls here, and they never danced before. There will be some songs, during each song, there must be exactly one boy and one girl are dancing. Besides, there is a special rule:  either the boy in the dancing pair must dance for the first time (so, he didn't dance with anyone before);  or the girl in the dancing pair must dance for the first time. 

Help Fox Ciel to make a schedule that they can dance as many songs as possible.


-----Input-----

The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of boys and girls in the dancing room.


-----Output-----

In the first line print k — the number of songs during which they can dance. Then in the following k lines, print the indexes of boys and girls dancing during songs chronologically. You can assume that the boys are indexed from 1 to n, and the girls are indexed from 1 to m.


-----Examples-----
Input
2 1

Output
2
1 1
2 1

Input
2 2

Output
3
1 1
1 2
2 2



-----Note-----

In test case 1, there are 2 boys and 1 girl. We can have 2 dances: the 1st boy and 1st girl (during the first song), the 2nd boy and 1st girl (during the second song).

And in test case 2, we have 2 boys with 2 girls, the answer is 3.

Difficulty: EASY
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
(b, g) = map(int, input().split())
print(b + g - 1)
for i in range(1, g + 1):
	print('%d %d' % (1, i))
for i in range(2, b + 1):
	print('%d %d' % (i, 1))


(a, b) = map(int, input().split())
m = b + a - 1
print(m)
for i in range(m):
	while a > 0:
		print(a, '', b)
		a -= 1
	b -= 1
	while b > 0:
		print(1, '', b)
		b -= 1


(n, m) = [int(x) for x in input().split()]
a = min(n, m)
b = abs(n - m)
k = 2 * a - 1 + b
print(k)
if a == 1:
	print(1, 1)
	i = 1
else:
	for i in range(1, a):
		print(i, i)
		print(i + 1, i)
	print(i + 1, i + 1)
if n < m:
	for i in range(a + 1, m + 1):
		print(a, i)
elif n > m:
	for i in range(a + 1, n + 1):
		print(i, a)


(n, m) = map(int, input().split())
print(n + m - 1)
for i in range(m):
	print('1 ' + str(i + 1))
for i in range(1, n):
	print(str(i + 1) + ' 1')


def ciel_dance(b, g):
	total = b + g - 1
	print(total)
	for i in range(b):
		print(i + 1, 1)
	for i in range(2, g + 1):
		print(1, i)
(b, g) = map(int, input().split())
ciel_dance(b, g)


(b, g) = list(map(int, input().split()))
print(b + g - 1)
for i in range(1, min(b, g) + 1):
	if b > g:
		print('1' + ' ' + str(i))
	else:
		print(str(i) + ' ' + '1')
for i in range(2, max(b, g) + 1):
	if b > g:
		print(str(i) + ' ' + '1')
	else:
		print('1' + ' ' + str(i))


t = input().split()
n = int(t[0])
m = int(t[1])
print(n + m - 1)
for i in range(m):
	print(1, i + 1)
for i in range(1, n):
	print(i + 1, 1)


def main():
	nm = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	nos = 0
	pairs = []
	for i in range(1):
		for j in range(m):
			pairs.append([i + 1, j + 1])
			nos += 1
	for j in range(1, n):
		pairs.append([j + 1, 1])
		nos += 1
	print(nos)
	for i in pairs:
		pair = str(i[0]) + ' ' + str(i[1])
		print(pair)
main()


__author__ = 'Ol4a'
(m, d) = list(map(int, input().split()))
k = m + d - 1
print(k)
for i in range(1, d + 1):
	print(1, i)
for j in range(2, m + 1):
	print(j, 1)


(n, m) = [int(i) for i in input().split()]
print(n + m - 1)
for i in range(m):
	print(1, i + 1)
for j in range(2, n + 1):
	print(j, 1)


def takeinput():
	(b, g) = map(int, input().split())
	boy = [0] * b
	girl = [0] * g
	ans = []
	sum = -1
	for i in range(b):
		for j in range(g):
			if boy[i] == 0 or girl[j] == 0:
				temp = i + j
				if temp > sum:
					boy[i] = 1
					girl[j] = 1
					sum = temp
					ans.append((i + 1, j + 1))
	return ans
res = takeinput()
print(len(res))
for val in res:
	print(val[0], val[1])


def Comp(n, m):
	count = n + m - 1
	print(str(count))
	print('1 1')
	for i in range(2, m + 1):
		print('1 ' + str(i))
	for i in range(2, n + 1):
		print(str(i) + ' 1')
Comp(*list(map(int, input().split())))


(n, m) = map(int, input().split())
(x, y) = ([0] * (n + 1), [0] * (m + 1))
l = []
for i in range(1, n + 1):
	for j in range(1, m + 1):
		if x[i] == 0:
			if [i, j] not in l and [j, i] not in l:
				l.append([i, j])
				x[i] += 1
				y[j] += 1
		elif y[j] == 0:
			if [i, j] not in l and [j, i] not in l:
				l.append([i, j])
				x[i] += 1
				y[j] += 1
print(len(l))
for i in l:
	print(*i)


(boys, girls) = list(map(int, input().split()))
h = 1
i = 1
print(boys + girls - 1)
while h <= boys:
	while i <= girls:
		print(h, i)
		i += 1
	h += 1
	if h > boys:
		break
	print(h, i - 1)


(a, b) = list(map(int, input().split()))
print(a + b - 1)
print(1, 1)
for i in range(2, b + 1):
	print(1, i)
for i in range(2, a + 1):
	print(i, 1)


(boys, girls) = input().split()
boys = int(boys)
girls = int(girls)
print(boys + girls - 1)
for i in range(1, girls + 1):
	print(1, i)
for i in range(2, boys + 1):
	print(i, girls)


import sys
import math
import itertools
import collections

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(n, m) = mi()
print(n + m - 1)
for i in range(m):
	print(1, i + 1)
for i in range(1, n):
	print(i + 1, 1)


(n, m) = [int(x) for x in input().split()]
print(n + m - 1)
for i in range(1, n + 1):
	print(i, 1)
if m > 1:
	for i in range(2, m + 1):
		print(1, i)


datos = input().split()
n = int(datos[0])
m = int(datos[1])
canciones = n + m - 1
print(canciones)
for i in range(m):
	print(str(1) + ' ' + str(i + 1))
for i in range(1, n):
	print(str(i + 1) + ' ' + str(m))


(n, m) = map(int, input().split())
print(n + m - 1)
for i in range(1, m + 1):
	print('{} {}'.format(1, i))
for i in range(2, n + 1):
	print('{} {}'.format(i, 1))


(n, m) = map(int, input().split())
l = []
r = []
for j in range(1, 2):
	for k in range(1, m + 1):
		l.append([j, k])
for k in range(2, n + 1):
	l.append([k, 1])
print(len(l))
for j in range(len(l)):
	print(*l[j])


L = [int(it) for it in input().split()]
n = L[0]
m = L[1]
(i, j, k) = (1, 1, 0)
out = []
while i <= n or j <= m:
	s = str(i) + ' ' + str(j)
	out.append(s)
	if i < n and j < m:
		if k % 2 == 0:
			j += 1
		else:
			i += 1
	elif i < n:
		i += 1
	elif j < m:
		j += 1
	else:
		break
	k += 1
print(len(out))
for item in out:
	print(item)


(n, m) = list(map(int, input().split()))
print(n + m - 1)
for i in range(n):
	print(i + 1, 1)
for j in range(1, m, 1):
	print(1, j + 1)


sa = input().split(' ')
boys = int(sa[0])
girls = int(sa[1])
dlist = []
if boys == girls:
	for x in range(1, boys):
		dlist.append([x, x])
		dlist.append([x, x + 1])
	dlist.append([boys, boys])
	print(len(dlist))
	for element in dlist:
		print(str(element[0]) + ' ' + str(element[1]))
elif boys < girls:
	for x in range(1, boys):
		dlist.append([x, x])
		dlist.append([x, x + 1])
	for y in range(boys, girls + 1):
		dlist.append([boys, y])
	print(len(dlist))
	for element in dlist:
		print(str(element[0]) + ' ' + str(element[1]))
else:
	(boys, girls) = (girls, boys)
	for x in range(1, boys):
		dlist.append([x, x])
		dlist.append([x, x + 1])
	for y in range(boys, girls + 1):
		dlist.append([boys, y])
	print(len(dlist))
	for element in dlist:
		print(str(element[1]) + ' ' + str(element[0]))


(n, m) = map(int, input().split())
print(n + m - 1)
t = []
t = [str(i) + ' ' + '1' for i in range(1, n + 1)] + [str(n) + ' ' + str(i) for i in range(2, m + 1)]
print('\n'.join(t))


(n, m) = map(int, input().split())
x = n + m
if x > 1:
	c = 1
	x = x - 2
	while x:
		x -= 1
		c += 1
	print(c)
	for i in range(1, m + 1):
		print(1, i)
	for j in range(2, n + 1):
		print(j, 1)
else:
	print(0)


(n, m) = tuple(input().split())
(n, m) = (int(n), int(m))
boys = [a for a in range(1, n + 1)]
girls = [a for a in range(1, m + 1)]
u_boys = [0 for a in range(n)]
u_girls = [0 for a in range(m)]
arr = []
count = 0
for boy in boys:
	for girl in girls:
		if u_boys[boy - 1] == 0 or u_girls[girl - 1] == 0:
			count = count + 1
			arr.append(str(boy) + ' ' + str(girl))
			u_boys[boy - 1] = 1
			u_girls[girl - 1] = 1
print(count)
print('\n'.join(arr))


(a, b) = str(input()).split()
a = int(a)
b = int(b)
min_v = min(a, b)
max_v = max(a, b)
print(a + b - 1)
lines = list()
print('1 1')
for i in range(2, a + 1):
	print(str(i) + ' 1')
for i in range(2, b + 1):
	print('1 ' + str(i))


(n, m) = map(int, input().split())
total = n - 1 + (m - 1) + 1
print(total)
print('1 1')
for i in range(n - 1):
	print(i + 2, end=' ')
	print(1)
for i in range(m - 1):
	print(1, end=' ')
	print(i + 2)


t = input().split()
(n, m) = (int(t[0]), int(t[1]))
res = []
for i in range(1, m + 1):
	res.append([1, i])
if n > 1:
	for i in range(2, n + 1):
		res.append([i, 1])
print(len(res))
for i in res:
	print(i[0], i[1])


(n, m) = map(int, input().split())
f = []
a = []
b = []
for k in range(1, n + 1):
	for j in range(1, m + 1):
		if k not in a:
			if j not in b:
				a.append(k)
				b.append(j)
				f.append([k, j])
			else:
				a.append(k)
				f.append([k, j])
		if j not in b:
			if k in a:
				b.append(j)
				f.append([k, j])
			else:
				a.append(k)
				b.append(j)
				f.append([k, j])
print(len(f))
for k in f:
	print(*k)


(n, m) = map(int, input().split())
print(n + m - 1)
if n == max(n, m):
	for i in range(1, n + 1):
		print(i, 1)
	for i in range(2, m + 1):
		print(n, i)
else:
	for i in range(1, m + 1):
		print(1, i)
	for i in range(2, n + 1):
		print(i, m)


input_list = [int(i) for i in input().split()]
n = input_list[0]
m = input_list[1]
print(n + m - 1)
for i in range(1, m + 1):
	print(1, i)
for i in range(2, n + 1):
	print(i, m)


import sys
import math
(n, m) = [int(x) for x in sys.stdin.readline().split()]
print(n + m - 1)
for i in range(1, m + 1):
	print(str(1) + ' ' + str(i))
for j in range(2, n + 1):
	print(str(j) + ' ' + str(m))


(n, m) = map(int, input().split())
print(n + m - 1)
boys = list(range(1, n + 1))
girls = list(range(1, m + 1))
path = list(zip(boys, girls))
path += list(zip(boys, girls[1:]))
if n < m:
	path += [(n, i) for i in girls[n + 1:]]
else:
	path += [(i, m) for i in boys[m:]]
path.sort()
for (x, y) in path:
	print(x, y)


(n, m) = list(map(int, input().split()))
print(n + m - 1)
if n + m == 1:
	print(1, 1)
elif m > 1:
	for i in range(1, n + 1):
		print(i, 1)
	for i in range(2, m + 1):
		print(1, i)
else:
	for i in range(2, n + 1):
		print(i, 1)
	for i in range(1, m + 1):
		print(1, i)


(n, m) = map(int, input().split())
ans = []
for x in range(1, m + 1):
	ans += [['1', str(x)]]
for x in range(2, n + 1):
	ans += [[str(x), '1']]
print(len(ans))
print('\n'.join(map(' '.join, ans)))


(n, m) = map(int, input().split())
girls = set()
boys = set()
ans = []
for i in range(1, n + 1):
	for j in range(1, m + 1):
		if i not in girls:
			ans.append((i, j))
			girls.add(i)
		elif j not in boys:
			ans.append((i, j))
			boys.add(j)
print(len(ans))
for i in ans:
	print(*i)


(b, g) = map(int, input().split())
print(g + b - 1)
for i in range(1, b + 1):
	for j in range(1, g + 1):
		print(i, j)
		if i > 1:
			break


class CielandDancing:
	n = 0
	m = 0

	def solve(self):
		print(self.n + self.m - 1)
		for i in range(1, self.m + 1):
			print(1, ' ', i)
		for i in range(2, self.n + 1):
			print(i, ' ', 1)
c = CielandDancing()
(c.n, c.m) = map(int, input().split())
c.solve()


(a, b) = map(int, input().split())
aa = []
bb = []
ans = []
lis = []
liss = []
for t in range(1, a + 1):
	aa.append(t)
for t in range(1, b + 1):
	bb.append(t)
for m in range(len(aa)):
	mm = aa[m]
	for n in range(len(bb)):
		nn = bb[n]
		if mm + nn not in ans:
			ans.append(mm + nn)
			lis.append(mm)
			liss.append(nn)
print(len(ans))
for t in range(len(lis)):
	v = lis[t]
	vv = liss[t]
	print(v, vv)


(n, m) = map(int, input().split())
r = n + m - 1
print(r)
if n == m:
	for i in range(1, n + 1):
		if i == 1:
			for j in range(1, m + 1):
				print(i, j)
		else:
			for j in range(2, m + 1):
				if i == j:
					print(i, j)
else:
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			print(i, j)
			if i > 1:
				break


(a, b) = [int(i) for i in input().split(' ')]
print(a + b - 1)
for i in range(1, b + 1):
	print(1, i)
if a > 1:
	for i in range(2, a + 1):
		print(i, 1)


a = input().split()
boys = int(a[0])
girls = int(a[1])
print(boys + girls - 1)
for x in range(0, boys):
	print(str(x + 1) + ' ' + '1')
for y in range(1, girls):
	print('1' + ' ' + str(y + 1))


import sys, math
sys.setrecursionlimit(10 ** 8)
(n, m) = map(int, input().split())
print(n + m - 1)
for i in range(1, m + 1):
	print(1, i)
for i in range(2, n + 1):
	print(i, 1)


data = input().split(' ')
boys = int(data[0])
girls = int(data[1])
total = boys + (girls - 1)
print(total)
for g in range(girls):
	print('1 %s' % (g + 1))
for b in range(1, boys):
	print('%s %s' % (b + 1, girls))


(v, m) = [int(i) for i in input().split()]
vm = v > m
t = v + m
iv = 1
im = 1
print(t - 1)
for i in range(1, t):
	print(iv, im)
	if vm:
		iv += 1 if i < v else 0
		im += 1 if i >= v else 0
	else:
		iv += 1 if i >= m else 0
		im += 1 if i < m else 0


class CodeforcesTask322ASolution:

	def __init__(self):
		self.result = ''
		self.n_m = []

	def read_input(self):
		self.n_m = [int(x) for x in input().split(' ')]

	def process_task(self):
		res = []
		res.append(str(sum(self.n_m) - 1))
		res.append('1 1')
		for x in range(2, self.n_m[0] + 1):
			res.append(f'{x} 1')
		for x in range(2, self.n_m[1] + 1):
			res.append(f'1 {x}')
		self.result = '\n'.join(res)

	def get_result(self):
		return self.result
Solution = CodeforcesTask322ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, m) = map(int, input().split())
print(m + n - 1)
for i in range(1, n + 1):
	if i == 1:
		for j in range(1, m + 1):
			print(i, ' ', j)
	else:
		print(i, ' ', 1)


(b, g) = map(int, input().split())
ans = b + g - 1
print(ans)
if b > g:
	for i in range(1, b + 1):
		print(i, 1)
	for i in range(2, g + 1):
		print(1, i)
else:
	for i in range(1, b + 1):
		print(i, 1)
	for i in range(2, g + 1):
		print(1, i)


(n, m) = map(int, input().split())
l = []
for i in range(1, m + 1):
	l.append(1)
	l.append(i)
for i in range(2, n + 1):
	l.append(i)
	l.append(1)
i = 0
print(len(l) // 2)
while i + 1 < len(l):
	print(l[i], l[i + 1])
	i = i + 2


[n, m] = [int(x) for x in input().split()]
nlist = list(range(1, n + 1))
mlist = list(range(1, m + 1))
k = 0
ans = []
if n > m:
	for i in range(1, m + 1):
		for j in range(1, n + 1):
			if i in mlist or j in nlist:
				ans.append([j, i])
				k += 1
				if i in mlist:
					mlist.remove(i)
				if j in nlist:
					nlist.remove(j)
else:
	for i in range(1, n + 1):
		for j in range(1, m + 1):
			if i in nlist or j in mlist:
				ans.append([i, j])
				k += 1
				if i in nlist:
					nlist.remove(i)
				if j in mlist:
					mlist.remove(j)
print(k)
for i in ans:
	print(*i)


from typing import List

class Solution:

	def main(self):
		answer = 0
		self.ciel_and_dancing()
		return answer

	def watermelon(self, n: int) -> int:
		return n % 2 == 0 and n != 2

	def way_too_long_words(self, n: int, s: List[str]) -> List[str]:
		ret_list = []
		for i in range(n):
			cur = s[i]
			ret = ''
			if len(s[i]) <= 10:
				ret_list.append(cur)
			else:
				ret += cur[0]
				ret += str(len(cur[1:len(cur) - 1]))
				ret += cur[-1]
				ret_list.append(ret)
		return ret_list

	def a_team(self, n: int, list: List[List[int]]) -> List[List[int]]:
		ret_list = 0
		for i in range(n):
			current = list[i]
			ret = int(current[0]) ^ int(current[1]) ^ int(current[2])
			if current[0] == current[1] and current[1] == current[2] and (current[0] == 1):
				ret = 0
			elif current[0] == current[1] and current[1] == current[2] and (current[0] == 0):
				ret = 1
			if ret == 0:
				ret_list += 1
		return ret_list

	def next_round(self, n: int, k: int, list: List[int]) -> int:
		ret = 0
		print('length: ' + str(len(list)))
		for i in range(len(list)):
			if int(list[i]) >= int(list[k - 1]) and int(list[i]) >= 1:
				ret += 1
		return ret

	def a_bit_plusplus(self):
		n = int(input())
		x = 0
		while n > 0:
			str = input()
			if '+' in str:
				x += 1
			else:
				x -= 1
			n -= 1
		return x

	def petya_and_strings(self):
		str1 = input()
		str2 = input()
		length = len(str1)
		i = 0
		str1 = str1.lower()
		str2 = str2.lower()
		isDone = False
		ret = 0
		while i < length and isDone == False:
			if str1[i] < str2[i]:
				isDone = True
				ret = -1
			elif str1[i] > str2[i]:
				isDone = True
				ret = 1
			i += 1
		return ret

	def beautiful_matrix(self):
		i = 5
		matrix = []
		while i > 0:
			matrix.append(input().replace(' ', ''))
			i -= 1
		for k in range(0, 5):
			for j in range(0, 5):
				if matrix[k][j] == '1':
					ret = abs(j - 2) + abs(k - 2)
					break
		return ret

	def helpful_maths(self):
		stri = input()
		splitt = stri.split('+')
		for i in range(len(splitt)):
			splitt[i] = int(splitt[i])
		splitt = sorted(splitt, key=lambda x: x)
		ret = ''
		for i in range(len(splitt)):
			x = str(splitt[i])
			if i == len(splitt) - 1:
				ret += '' + x
			else:
				ret += '' + x + '+'
		return ret

	def word_capitalization(self):
		s = input()
		ret = ''
		ret += s[0].upper() + s[1:]
		return ret

	def stones_on_the_table(self):
		count = 0
		n = int(input())
		s = input()
		for i in range(1, len(s)):
			if s[i] == s[i - 1]:
				count += 1
		return count

	def boy_or_girl(self):
		ret = 'CHAT WITH HER!'
		s = input()
		sett = set()
		count = 0
		for i in range(len(s)):
			if s[i] not in sett:
				count += 1
				sett.add(s[i])
		if count % 2 != 0:
			ret = 'IGNORE HIM!'
		return ret

	def football(self):
		ret = 'NO'
		i = 0
		j = 0
		s = input()
		for k in range(len(s)):
			if s[k] == s[j]:
				i += 1
			else:
				j = k
				i = k
			if i - j == 6:
				ret = 'YES'
				break
		return ret

	def hq9_plus(self):
		ret = 'NO'
		s = input()
		n = len(s)
		sett = set(['H', 'Q', '9'])
		for i in range(n):
			if s[i] in sett:
				ret = 'YES'
				break
		return ret

	def even_odds(self):
		ret = 0
		s = input()
		(n, k) = s.split(' ')
		(n, k) = (int(n), int(k))
		if k <= (n + 1) // 2:
			ret = k * 2 - 1
		else:
			ret = (k - (n + 1) // 2) * 2
		return int(ret)

	def string_task(self):
		ret = ''
		s = input()
		n = len(s)
		s = s.lower()
		vowels = set(['a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y'])
		for i in range(n):
			if s[i] not in vowels:
				ret += '.' + s[i]
		return ret

	def young_physicist(self):
		ret = 'NO'
		n = int(input())
		i = n
		a = []
		(x, y, z) = (0, 0, 0)
		while i > 0:
			s = input()
			a = s.split(' ')
			(a[0], a[1], a[2]) = (int(a[0]), int(a[1]), int(a[2]))
			x += a[0]
			y += a[1]
			z += a[2]
			i -= 1
		if x == y and y == z and (x == 0):
			ret = 'YES'
		return ret

	def ciel_and_dancing(self):
		s = input()
		(n, m) = s.split(' ')
		(n, m) = (int(n), int(m))
		print(n + m - 1)
		for i in range(1, m + 1):
			print('1 ' + str(i))
		for i in range(2, n + 1):
			print(str(i) + ' 1')
x = Solution()
answer = x.main()


import sys
tmp = list(map(int, input().split()))
m = tmp[0]
n = tmp[1]
print(m + n - 1)
for i in range(1, m + 1):
	print(i, 1)
for i in range(2, n + 1):
	print(1, i)


import sys
got = list(map(int, input().split()))
boys = got[0]
girls = got[1]
sys.stdout.write(str(boys + girls - 1) + '\n')
for i in range(1, girls + 1):
	sys.stdout.write('1 ' + str(i) + '\n')
for i in range(2, boys + 1):
	sys.stdout.write(str(i) + ' 1\n')


(n, m) = map(int, input().split())
r1 = n + m - 1
print(r1)
for i in range(1, n + 1):
	for j in range(1, m + 1):
		print(i, j)
		if i > 1:
			break


numbers = input().split()
n = int(numbers[0])
m = int(numbers[1])
print(n + m - 1)
i = 1
while i <= m:
	print('1 ' + str(i))
	i = i + 1
i = 2
while i <= n:
	print(str(i) + ' 1')
	i = i + 1


def A():
	(n, m) = map(int, input().split())
	print(m + n - 1)
	for i in range(1, m + 1):
		print(1, i)
	for j in range(2, n + 1):
		print(j, 1)
A()


def solve(n, m):
	count = n + m - 1
	print(count)
	for i in range(1, n + 1):
		print(i, 1)
	for j in range(2, m + 1):
		print(1, j)

def main():
	arr = list(map(int, input().split(' ')))
	solve(*arr)
main()


import sys
(n, m) = map(int, sys.stdin.readline().split())
print(n + m - 1)
for i in range(m):
	print(1, i + 1)
for i in range(1, n):
	print(i + 1, 1)


(n, m) = list(map(int, input().split()))
ans = []
for i in range(2, n + 1):
	ans.append((i, 1))
for i in range(2, m + 1):
	ans.append((1, i))
print(len(ans) + 1)
print(1, 1)
for i in ans:
	print(*i)


from itertools import combinations

def solve(n, m):
	print(n + m - 1)
	for i in range(1, m + 1):
		print(1, ' ', i)
	for i in range(2, n + 1):
		print(i, ' ', 1)
(n, m) = map(int, input().split(' '))
solve(n, m)


(x, y) = map(int, input().split())
(z, x1, y1) = ([], [], [])
for i in range(1, x + 1):
	for j in range(1, y + 1):
		if i not in x1 or j not in y1:
			x1.append(i)
			y1.append(j)
			z.append((i, j))
print(len(z))
for i in z:
	print(*i)


(n, m) = map(int, input().split())
s = list()
if n > m:
	for i in range(1, n + 1):
		s.append((i, 1))
	for i in range(2, m + 1):
		s.append((n, i))
else:
	for i in range(1, m + 1):
		s.append((1, i))
	for i in range(n, 1, -1):
		s.append((i, m))
print(len(s))
for i in s:
	print(i[0], i[1])


a = list(map(int, input().split()))
print(sum(a) - 1)
for i in range(a[0]):
	print(i + 1, 1)
for i in range(a[1] - 1):
	print(1, i + 2)


def main():
	(n, m) = map(int, input().strip().split())
	print(n + m - 1)
	for i in range(1, n + 1):
		print(i, 1)
	for i in range(2, m + 1):
		print(n, i)
main()


(n, m) = map(int, input().split())
count = n + m - 1
n1 = 1
m1 = 0
if n > m:
	n1 = 1
	m1 = 0
elif n == m:
	n1 = 1
	m1 = 0
else:
	n1 = 0
	m1 = 1
print(count)
i = 0
if n1 == 1:
	while i != count:
		i += 1
		if m1 == m:
			n1 += 1
		else:
			m1 += 1
		print(n1, m1)
else:
	while i != count:
		i += 1
		if n1 == n:
			m1 += 1
		else:
			n1 += 1
		print(n1, m1)


(n, m) = list(map(int, input().split()))
ma = list(range(1, m + 1))
lk = len(ma)
sa = 0
ta = list(range(2, n + 1))
sa = lk + len(list(range(2, n + 1)))
print(sa)
for x in range(1, m + 1):
	print(1, x)
for x in range(2, n + 1):
	print(x, 1)


(a, b) = map(int, input().split())
print(a + b - 1)
for i in range(1, a + b):
	print(max(1, i - b + 1), min(i, b))


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
(n, m) = rinput()
print(n + m - 1)
s = []
for i in range(n):
	print(i + 1, 1)
for i in range(m - 1):
	print(1, i + 2)


sez = [int(i) for i in input().split()]
a = []
if sez[0] > sez[1]:
	for i in range(sez[1]):
		a.append([1, i + 1])
	for j in range(1, sez[0]):
		a.append([j + 1, 1])
else:
	for i in range(sez[0]):
		a.append([i + 1, 1])
	for j in range(1, sez[1]):
		a.append([1, j + 1])
print(len(a))
for i in a:
	print(' '.join([str(j) for j in i]))


(n, m) = map(int, input().split())
res = []
db = set()
dg = set()
for i in range(n):
	for j in range(m):
		if i not in db or j not in dg:
			res += ['%d %d' % (i + 1, j + 1)]
		dg.add(j)
		db.add(i)
print(len(res))
print('\n'.join(res))


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n, m) = I()
ans = []
for i in range(1, m + 1):
	ans.append([1, i])
for i in range(2, n + 1):
	ans.append([i, 1])
print(len(ans))
for i in ans:
	print(*i)


def main():
	(x, y) = map(int, input().split())
	cx = [0] * x
	cy = [0] * y
	print(x + y - 1)
	for i in range(x):
		for j in range(y):
			if cx[i] == 0 or cy[j] == 0:
				print(i + 1, j + 1)
				cx[i] = 1
				cy[j] = 1
main()


(n, m) = map(int, input().split())
ii = set()
jj = set()
ans = []
for i in range(1, n + 1):
	for j in range(1, m + 1):
		if i not in ii or j not in jj:
			ans.append((i, j))
			ii.add(i)
			jj.add(j)
print(len(ans))
for (a, b) in ans:
	print(a, b)


import sys
f = sys.stdin
(m, l) = map(int, f.readline().split())
print(m + l - 1)
for i in range(1, l + 1):
	print(1, i)
for i in range(2, m + 1):
	print(i, 1)


b = list(map(int, input().split()))
k = b[0] + b[1] - 1
print(k)
d = [1, 1]
print(*d)
if k > 1:
	for i in range(1, k):
		if b[0] > b[1]:
			if d[1] < b[1]:
				if d[0] == d[1]:
					d[0] += 1
					print(*d)
				elif d[0] > d[1]:
					d[1] += 1
					print(*d)
			else:
				d[0] += 1
				print(*d)
		elif b[0] < b[1]:
			if d[0] < b[0]:
				if d[0] == d[1]:
					d[1] += 1
					print(*d)
				elif d[1] > d[0]:
					d[0] += 1
					print(*d)
			else:
				d[1] += 1
				print(*d)
		elif d[0] == d[1]:
			d[0] += 1
			print(*d)
		elif d[0] > d[1]:
			d[1] += 1
			print(*d)


def solution(n, m):
	print(m + n - 1)
	if n >= m:
		for i in range(1, m + 1):
			print(1, i)
		for i in range(2, n + 1):
			print(i, 1)
	else:
		for i in range(1, n + 1):
			print(i, 1)
		for i in range(2, m + 1):
			print(1, i)
a = list(map(int, input('').split()))
solution(a[0], a[1])


X = list(map(int, input().split()))
Answers = []
for i in range(X[1]):
	Answers.append('1' + ' ' + str(i + 1))
for i in range(1, X[0]):
	Answers.append(str(i + 1) + ' ' + '1')
print(len(Answers))
print(*Answers, sep='\n')


(n, m) = map(int, input().split())
k = n + m - 1
i = j = 1
print(k)
if n == m:
	while i < n and j < m:
		print(i, j)
		print(i, j + 1)
		i += 1
		j += 1
	print(i, j)
else:
	print(i, j)
	i += 1
	j += 1
	while i <= n and j <= m:
		print(i - 1, j)
		print(i, j)
		i += 1
		j += 1
	while i <= n:
		print(i, j - 1)
		i += 1
	while j <= m:
		print(i - 1, j)
		j += 1


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(a, b) = value()
ans = set()
for i in range(1, a + 1):
	ans.add((i, 1))
for i in range(1, b + 1):
	ans.add((1, i))
print(len(ans))
for i in ans:
	print(*i)


(n, m) = map(int, input().split())
n_bool = []
m_bool = []
indexs = []
song = 0
for i in range(n):
	n_bool.append(True)
for j in range(m):
	m_bool.append(True)
for a in range(n):
	for b in range(m):
		if n_bool[a] == True or m_bool[b] == True:
			song += 1
			indexs.append(str(a + 1) + ' ' + str(b + 1))
			n_bool[a] = False
			m_bool[b] = False
print(song)
for c in range(len(indexs)):
	print(indexs[c])


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = 'sonhuytran@gmail.com'
__doc__ = ''
__version__ = '1.0'

def main() -> int:
	(n, m) = map(int, input().split())
	print(n + m - 1)
	for i in range(1, m + 1):
		print('1 %d' % i)
	for i in range(2, n + 1):
		print('%d 1' % i)
	return 0
exit(main())


a = list(map(int, input().split()))
b = [False for i in range(0, 101)]
f = [False for i in range(0, 101)]
sol = []
for i in range(1, a[0] + 1):
	for j in range(1, a[1] + 1):
		if not b[i] or not f[j]:
			b[i] = True
			f[j] = True
			sol.append((i, j))
print(len(sol))
for x in sol:
	print('%i %i' % x)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
(n, m) = L()
print(n + m - 1)
for i in range(1, n + 1):
	print(i, 1)
for j in range(2, m + 1):
	print(1, j)
endtime = time.time()


def solve(n, m):
	print(n + m - 1)
	for i in range(1, m + 1):
		print('1' + ' ' + str(i))
	for i in range(2, n + 1):
		print(str(i) + ' ' + '1')
(n, m) = map(int, input().split())
solve(n, m)


(n, m) = map(int, input().split())
i = 1
j = 1
print(n + m - 1)
while j <= m:
	print(i, j)
	if j == m:
		break
	j += 1
while i < n:
	i += 1
	print(i, j)