# $language = "Python"
# $interface = "1.0"
# Connect to a telnet server and automate the initial login sequence.
# Note that synchronous mode is enabled to prevent server output from
# potentially being missed.
def my_backshape(n):
x_director = [0,1,0,-1]
y_director = [1,0,-1,0]
i = 0
j = -1
flag = 0
result = 0
matrix = [[0]*n]*n
while (flag == 0):
flag = 1
for k in range(0,4):
temp_x = i + x_director[k]
temp_y = j + y_director[k]
while(matrix[temp_x][temp_y]==0 and temp_x<n and temp_y<n and temp_x>-1 and temp_y>-1):
matrix[temp_x][temp_y] = result
result = result + 1
flag = 0
i = temp_x
j = temp_x
temp_x = temp_x + x_director[k]
temp_y = temp_y + y_director[k]
print result,
print " "
my_backshape(4)