# Ian Binstock
# 6/1/2026
# Program that calculates pascal's triangle

def main():
    n = int(input("How many rows of Pascal's Triangle?\n"))
    
    # We will set a hard cap, so that we don't print rows that are too long to display in the terminal
    MAX_WIDTH = 80

    # triangle will hold our rows (a list of lists)
    triangle = []

    for i in range(n):
        # Create the new row
        row = []
        for j in range(i + 1):
            if j == 0 or j == i:
                # The first and last numbers in every row are always 1
                row.append(1)
            else:
                # Add the two numbers from the row above it
                left_above = triangle[i-1][j-1]
                right_above = triangle[i-1][j]
                row.append(left_above + right_above)
        
        # Add the completed row to our triangle list
        triangle.append(row)

        # [SKIPPED OVER] Check the width before printing
        row_width = 0
        for num in row:
            row_width = row_width + len(str(num)) + 1

        # [SKIPPED OVER] Only print if it fits on the screen
        if row_width <= MAX_WIDTH:
            num_spaces = (MAX_WIDTH - row_width) // 2
            for s in range(num_spaces):
                print(" ", end="")

            # Print the actual numbers in the row
            for num in row:
                print(num, end=" ")
            
            # Move to the next line
            print()

main()