import java.util.*;
/**
 * A01 - Octagon
 * Prints an octagon of user-specified size
 * @author [Student Name]
 */
 
public class Program4 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int size = 0;
		boolean valid = true;
		
		/**
		 * asks the user to input a correct value
		 */	
		do {
			try {
				System.out.println("This program prints an octagon.");
				System.out.print("Please enter a size as an integer (1 - 12): ");
				size = input.nextInt();
				if (size >= 1 && size <= 12) valid = false;
					else System.out.println("Sorry. The size must be between 1 and 12. Please try again.");
			}
			catch (InputMismatchException e) {
				System.out.println("Sorry. The size must be an integer. Please try again.");
				input.next();
			}
		} while (valid);
		
		/**
		 * prints the upper third of the octagon
		 */
		for (int row = 0; row < size; row++) {
			System.out.print("\n");
			for (int col = 0; col < size*3; col++) {
				if (row == 0 && col < size) System.out.print(" ");
					else if (row == 0 && col < size*2) System.out.print("#");
				if (row == 1 && col < size-1) System.out.print(" ");
					else if (row == 1 && col < size*2 + 1) System.out.print("#");
				if (row == 2 && col < size-2) System.out.print(" ");
					else if (row == 2 && col < size*2 + 2) System.out.print("#");
				if (row == 3 && col < size-3) System.out.print(" ");
					else if (row == 3 && col < size*2 + 3) System.out.print("#");
				if (row == 4 && col < size-4) System.out.print(" ");
					else if (row == 4 && col < size*2 + 4) System.out.print("#");
				if (row == 5 && col < size-5) System.out.print(" ");
					else if (row == 5 && col < size*2 + 5) System.out.print("#");
				if (row == 6 && col < size-6) System.out.print(" ");
					else if (row == 6 && col < size*2 + 6) System.out.print("#");
				if (row == 7 && col < size-7) System.out.print(" ");
					else if (row == 7 && col < size*2 + 7) System.out.print("#");
				if (row == 8 && col < size-8) System.out.print(" ");
					else if (row == 8 && col < size*2 + 8) System.out.print("#");
				if (row == 9 && col < size-9) System.out.print(" ");
					else if (row == 9 && col < size*2 + 9) System.out.print("#");
				if (row == 10 && col < size-10) System.out.print(" ");
					else if (row == 10 && col < size*2 + 10) System.out.print("#");
				if (row == 11 && col < size-11) System.out.print(" ");
					else if (row == 11 && col < size*2 + 11) System.out.print("#");
			}
		}
		
		/**
		 * prints the middle third of the octagon
		 */
		for (int row = 0; row < size; row++) {
			System.out.print("\n");
			for (int col = 0; col < size*3; col++) {
				System.out.print("#");
			}
		}
		
		/**
		 * prints the bottom third of the octagon
		 */
		for (int row = 0; row < size; row++) {
			System.out.print("\n");
			for (int col = 0; col < size*3; col++) {
				if (row == 0 && col < 1) System.out.print(" ");
					else if (row == 0 && col < size*3 - 1) System.out.print("#");
				if (row == 1 && col < 2) System.out.print(" ");
					else if (row == 1 && col < size*3 - 2) System.out.print("#");
				if (row == 2 && col < 3) System.out.print(" ");
					else if (row == 2 && col < size*3 - 3) System.out.print("#");
				if (row == 3 && col < 4) System.out.print(" ");
					else if (row == 3 && col < size*3 - 4) System.out.print("#");
				if (row == 4 && col < 5) System.out.print(" ");
					else if (row == 4 && col < size*3 - 5) System.out.print("#");
				if (row == 5 && col < 6) System.out.print(" ");
					else if (row == 5 && col < size*3 - 6) System.out.print("#");
				if (row == 6 && col < 7) System.out.print(" ");
					else if (row == 6 && col < size*3 - 7) System.out.print("#");
				if (row == 7 && col < 8) System.out.print(" ");
					else if (row == 7 && col < size*3 - 8) System.out.print("#");
				if (row == 8 && col < 9) System.out.print(" ");
					else if (row == 8 && col < size*3 - 9) System.out.print("#");
				if (row == 9 && col < 10) System.out.print(" ");
					else if (row == 9 && col < size*3 - 10) System.out.print("#");
				if (row == 10 && col < 11) System.out.print(" ");
					else if (row == 10 && col < size*3 - 11) System.out.print("#");
				if (row == 11 && col < 12) System.out.print(" ");
					else if (row == 11 && col < size*3 - 12) System.out.print("#");
			}
		}
	}
}
