using System.Numerics; public class Program { public static void Main() { //int num = int.Parse(Console.ReadLine() ?? string.Empty); string[] str = (Console.ReadLine() ?? string.Empty).Trim().Split(' '); //string str = Console.ReadLine() ?? string.Empty; int h = int.Parse(str[0]); int w = int.Parse(str[1]); List ints = new List(); for(int i = 0; i < h; i++) { string[] str2 = (Console.ReadLine() ?? string.Empty).Trim().Split(' '); for (int j = 0; j < w; j++) { ints.Add(int.Parse(str2[j])); } } ints.Sort(); for(int i = 1;i <= ints.Count; i++) { Console.Write(ints[i-1]+" "); if(i % w == 0) { Console.WriteLine(); } } } }