#include using namespace std; int main(){ int h, w; cin >> h >> w; vector a(h*w); for(auto &&v: a)cin >> v; sort(a.begin(), a.end()); for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ if(x)cout<<' '; cout<