#include #define rep(i, x) for(ll i = 0; i < x; i++) #define rep2(i, x) for(ll i = 1; i <= x; i++) #define all(a) (a).begin(),(a).end() using ll = long long; using ld = long double; using namespace std; signed main() { ll n, m; cin >> n >> m; vector v(n * m); rep(i, n) { rep(j, m) { cin >> v[i * m + j]; } } sort(all(v)); rep(i, n) { rep(j, m) { if (j != 0) { cout << ' '; } cout << v[i * m + j]; } cout << endl; } return 0; }