Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

TAARR029 - Ma trận zíc-zắc dọc giảm dần

Sắp xếp lại các phần tử của một ma trận theo trật tự giảm dần theo đường zíc-zắc.

Input

Dòng 1: m, n - kích thước của ma trận, 0 < m, n < 50
m dòng tiếp theo, mỗi dòng có n số tự nhiên trong khoảng [-999, 999]

Output

Ma trận đã cho đã được sắp xếp lại theo thứ tự giảm dần theo đường zíc-zắc dọc, xuất phát từ góc dưới bên trái.

Example

Input:
5 10
   9 -10  16 -60 -58 -19 -62 -97  19  -8
 -56  72  59 -96  89  66 -51 -80  57  74
 -88 -87 -77  83  43 -83 -88 -68 -21  60
  30 -52  13 -59 -57  24  88 -29  -2  88
   9  66 -43  28  95  13 -75  26   8 -92

Output:
  83  74  28  26  -2  -8 -57 -58 -87 -88
  88  72  30  24   8 -10 -56 -59 -83 -88
  88  66  43  19   9 -19 -52 -60 -80 -92
  89  66  57  16   9 -21 -51 -62 -77 -96
  95  60  59  13  13 -29 -43 -68 -75 -97

Added by:Nguyễn Tuấn Anh
Date:2017-10-13
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.