## First Set Size
# The number of vertices in the first set.
## Second Set Size
# The number of vertices in the second set.


# If there is an error with one of the arguments, output the problems to
# stderr and then exit with status 1.

import sys # imported to get the command line arguments.

#################################################
# Arguments:     #
# sys.argv[0] = the path of this program #
# sys.argv[1] = the path of the output file #
# sys.argv[2] = the 1st argument  #
# sys.argv[3] = the 2nd argument  #
# ...      #
# sys.argv[n+1] = the nth argument  #
#################################################

# If there are too few arguments then one of the fields must not have
# been filled out.
if len(sys.argv) < 4:
    sys.stderr.write("Please fill out all fields.")
    exit(1)   # Exit with status 1

file_name = sys.argv[1]  # The file to which to output the sgf code.

m = 0  #size of set 1
n = 0  #size of set 2

try:
 # Attempts to set the number of vertices in set 1
    m = int(sys.argv[2])
except:
 # If m is not a number (contains non-numeric characters).
    sys.stderr.write("The size of set 1 must be a positive integer.")
    exit(1)

try:
 # Attempts to set the number of vertices in set 2
    n = int(sys.argv[3])
except:
 # If n is not a number (contains non-numeric characters).
    sys.stderr.write("The height must be a positive integer.")
    exit(1)

# m must be an integer in [1,60]
if m < 1 or m>60 :
 sys.stderr.write("The size of set 1 must be a postitive integer between 1 and 60.");
 exit(1)

# n must be an integer in [1,60]
if n < 1 or n>60:
 sys.stderr.write("The size of set 2 must be a postitive integer between 1 and 60.");
 exit(1)

vertices = m + n
edges = m*n


from math import *

output = open(file_name, 'w')
output.write(str(vertices) + " " + str(edges) + "\n")

for i in range(1,m + 1):
    for j in range(1,n + 1):
        output.write(str(i) + " " + str(m+j) + "\n")

x_m = 200
x_n = 600

y_spacing = 600/max([m , n])


for x in range(1,m + 1):
    a = int(round(x*600/m/10)*10)
    output.write(str(x_m) + " " + str(a) + "\n")

for y in range(1,n + 1):
    a = int(round(y*600/n/10)*10)
    output.write(str(x_n) + " " + str(a) + "\n")


output.close()