## Tree depth
# If d=depth, n=2^(d+1)-1


# If there is an error with the input, output the problem to
# stderr and then exit with status 1.

import sys	# imported to get the command line arguments.


# If there are too few arguments then one of the fields must not have
# been filled out.
if len(sys.argv) < 3:
    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.

d = 0  #tree depth


try:
	# Attempts to set the number of vertices in set 	
	d = 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)


# d must be an integer in [0,6]
if d < 0 or d > 6:
	sys.stderr.write("The tree depth must be a nonnegative integer between 0 and 6.");
	exit(1)

n = 2**(d+1)-1
vertices = n
edges = n-1

from math import *

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


#write n edge configs
for i in range(1,(n-1)/2 + 1):
    output.write(str(i) + " " + str(2*i) + "\n")
    output.write(str(i) + " " + str(2*i+1) + "\n")


#write locations of vertices
for j in range(d+1):  #loop over depth
	y = int(round((j+1.)/(d+1)*600/10)*10)
	for k in range(1,2**j+1):  #loop through row
		x = int(round((k/(2.**j+1))*800/10)*10)
		output.write(str(x) + " " + str(y) + "\n")

output.close()




