def main(): N = int(input()) As = [[0]*N for _ in range(N)] y, x = 0, 0 t = 1 down = True pivot_frag = True right_down = False while True: As[y][x] = t t += 1 if (y, x) == (N - 1, N - 1): break elif y == x: if pivot_frag: y += 1 pivot_frag = False right_down = True else: y += 1 x += 1 pivot_frag = True down = True elif y == (N - 1) and x % 2 == 0: y, x = x, y down = False left_up = False elif down: if right_down: y += 1 x += 1 right_down = False else: x -= 1 right_down = True else: if left_up: y -= 1 x -= 1 left_up = False else: y += 1 left_up = True for i in range(N): print(*As[i]) print() if __name__ == "__main__": main()