import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[][] matrix = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { matrix[i][j] = sc.nextInt(); } } for (int j = 0; j < n; j++) { int temp = matrix[j][j]; int row = j; for (int i = j; i < n; i++) { if (matrix[i][j] > temp) { temp = matrix[i][j]; row = i; } } for (int k = 0; k < n; k++) { int temp1 = matrix[j][k]; matrix[j][k] = matrix[row][k]; matrix[row][k] = temp1; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { System.out.print(matrix[i][j] + " "); } System.out.println(); } } }