Manao has invented a new mathematical term — a beautiful set of points. He calls a set of points on a plane beautiful if it meets the following conditions:
 1.  The coordinates of each point in the set are integers. 1.  For any two points from the set, the distance between them is a non-integer. 
Consider all points (*x*, *y*) which satisfy the inequations: 0 ≤ *x* ≤ *n*; 0 ≤ *y* ≤ *m*; *x* + *y* &gt; 0. Choose their subset of maximum size such that it is also a beautiful set of points.
The single line contains two space-separated integers *n* and *m* (1 ≤ *n*, *m* ≤ 100).
import sys, io, os
import math
import bisect
import heapq
import string
import re
from decimal import *
from collections import defaultdict,Counter,deque
input = sys.stdin.readline
sys.setrecursionlimit(100000) 
 
def I():
    return input()
 
def II():
    return int(input())
 
def MII():
    return map(int, input().split())
 
def LI():
    return list(input().split())
 
def LII():
    return list(map(int, input().split()))
 
def GMI():
    return map(lambda x: int(x) - 1, input().split())
 
def LGMI():
    return list(map(lambda x: int(x) - 1, input().split()))
 
def WRITE(out):
  return print('\n'.join(map(str, out)))
 
def WS(out):
  return print(' '.join(map(str, out)))
 
def WNS(out):
  return print(''.join(map(str, out)))

def WSNOPRINT(out):
  return ''.join(map(str, out))


'''
'''
def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError

def find_lt(a, x):
    'Find rightmost value less than x'
    i = bisect_left(a, x)
    if i:
        return a[i-1]
    raise ValueError

def find_le(a, x):
    'Find rightmost value less than or equal to x'
    i = bisect_right(a, x)
    if i:
        return a[i-1]
    raise ValueError

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bisect_right(a, x)
    if i != len(a):
        return a[i]
    raise ValueError

def find_ge(a, x):
    'Find leftmost item greater than or equal to x'
    i = bisect_left(a, x)
    if i != len(a):
        return a[i]
    raise ValueError

"""
(1,0) (

(a1-a2)^2 + (b1-b2)^2 != a square number
n, m <= 100
squares less than <= 2*10000

a^2 + b^2 = c^2
pythagorean triples such that c is <= 141?

all sets of points - pythagorean triples?

n 1
n-1 2

7-2, 3
5,3

n = 1
1 1
n = 2
2 1
1 2
"""
def squares(n):
    a = [1]
    i = 2 
    while a[-1] <= 2*n*n:
        a.append(i*i)
        i += 1
    return set(a)

def dickson(n,m):
    sq = squares(max(n,m))
    triples = []
    for s in range(n+1):
        for t in range(m+1):
            if s == 0 and t == 0:
                continue
            if 2*s*t in sq:
                r = int(math.sqrt(2*s*t))
                triples.append((r+s,r+t))
    return triples

def anti_dickson(n,m):
    sq = squares(max(n,m))
    ans = []
    for s in range(n+1):
        for t in range(m+1):
            if s == 0 and t == 0:
                continue
            if 2*s*t not in sq:
                ans.append((s,t))
    return ans

def solve():
    n, m = MII()
    ans = []
    if n == m:
        trip = dickson(n,m)
        trip = set([x+y-1 for x,y in trip])
        for i in range(n):
            ans.append((i,i+1))
        if n not in trip:
            ans.append((n,0))
    elif n > m:
        for i in range(m+1):
            ans.append((i+1,i))
    else:
        for i in range(n+1):
            ans.append((i,i+1))

    print(len(ans))
    for x,y in ans:
        print(x,y)

def main():
    solve()

main()
