#include #include #include #include #include #include #include #include #include #include using namespace std; int main(){ int h, w; cin >> h >> w; vector x(h*w); for (int i = 0; i < h*w; i++) cin >> x[i]; sort(x.begin(), x.end()); string delim = ""; int cnt = 0; for (auto y : x){ cout << delim << y; cnt++; delim = " "; if (!(cnt%w)){ cout << endl; cnt = 0; delim = ""; } } }