#include #pragma GCC optimize("O3") #define fi first #define se second #define vi vector #define vpi vector> #define vll vector #define vpll vector> #define si(v) int((v).size()) #define all(v) (v).begin(), (v).end() #define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) #define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i) #define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i) template void chmax(T &a, U b) { if (a < b) a = b; } template void chmin(T &a, U b) { if (a > b) a = b; } using ll = long long; using ld = long double; using namespace std; constexpr ll MOD = 1000000007; signed main() { cout << fixed << setprecision(20); ios::sync_with_stdio(false); cin.tie(0); 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 != 0 && i % w == 0) cout << endl; else if (i != 0) cout << " "; cout << a[i]; } cout << endl; return (0); }