import java.util.Scanner;

public class Main {
	private static Scanner in;

	public static void main(String[] args) {
		System.out.print("Enter a number:");
		in = new Scanner(System.in);
		int size = in.nextInt();
		if(size == 1){System.out.println(1); return;}
		
		int[] location = {0,0};
		int[][] field = new int[size][size];
		int count = 1; 
		int direction = 0; //0 = R, 1 = D, 2 = L, 3 = U

		while(count <= size*size){
			field[location[0]][location[1]] = count;
			if(direction == 0){
				if(location[1] + 1 >= size){direction++;}
				else if(field[location[0]][location[1]+1] >= 1){ //If occupied
						direction++;
					}
				}
			
			if(direction == 1){
				if(location[0] + 1 >= size){direction++;}
				else if(field[location[0]+1][location[1]] >= 1){ //If occupied
					direction++;
				}
			}
			
			if(direction == 2){
				if(location[1] - 1 < 0){direction++;}
				else if(field[location[0]][location[1]-1] >= 1){ //If occupied
						direction++;
					}
				}
			
			if(direction == 3){
				if(field[location[0]-1][location[1]] >= 1){ //If occupied
						direction = 0;
				}	
			}

			if(direction == 0){
				location[1]++;
			}
			else if(direction == 1){
				location[0]++;
			}
			else if(direction == 2){
				location[1]--;
			}
			else if(direction == 3){
				location[0]--;
			}
		count++;
		}
		for(int y = 0; y < size;y++){
			for(int x = 0; x < size; x++){
				System.out.print(field[y][x] + " ");
			}
			System.out.println();
		}
	  }	
}