#include using namespace std; int main() { int H, W; cin >> H, W; map mp; for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { int t; cin >> t; mp[t]++; } } int cur = 0; for (int i = 0; i < H; ++i) { for (int j = 0; j < W; ++j) { while (mp[cur] == 0) cur++; cout << cur << " "; mp[cur]--; } cout << endl; } return 0; }