// #define _GLIBCXX_DEBUG #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { // Input int H, W; cin >> H >> W; vector A(H * W); rep(i, H * W) cin >> A[i]; // Output sort(A.begin(), A.end()); vector> B(H, vector(W)); rep(i, H) rep(j, W) B[i][j] = A[i * W + j]; rep(i, H) { rep(j, W) { if (j) cout << ' '; cout << B[i][j]; } cout << '\n'; } }