#include #include #include void solve() { int h, w; std::cin >> h >> w; int n = h * w; std::vector xs(n); for (auto& x : xs) std::cin >> x; std::sort(xs.begin(), xs.end()); for (int i = 0; i < n; ++i) { std::cout << xs[i] << " "; if (i % w == w - 1) std::cout << "\n"; } } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }