#include #pragma GCC optimize("O3") #define ll long long #define ld long double #define fi first #define se second #define mp make_pair #define pi pair #define pll pair #define vi vector #define vll vector #define vpi vector> #define vpll vector> #define rep(i, n) for(ll i = 0; i < (n); ++i) #define rep2(i, a, b) for(ll i = a; i <= (b); ++i) #define rep3(i, a, b) for(ll i = a; i >= (b); --i) #define all(v) (v).begin(), (v).end() #define si(v) (int)(v).size() using namespace std; template using pq = priority_queue; template using pqg = priority_queue, greater>; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } constexpr ll MOD = 1000000007, MAX = 100005; signed main() { cout << fixed << setprecision(10); ios::sync_with_stdio(false); std::cin.tie(nullptr); int h, w; cin >> h >> w; vi a(h*w); rep(i, h*w) cin >> a[i]; sort(all(a)); rep(i, h*w) { if (i && (i % w == 0)) cout << '\n'; else if (i) cout << " "; cout << a[i]; } cout << "\n"; return (0); }