#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m;
void func(int y[m]){
for(int i = 0; i < m; i++){
for(int j = i; j < m; j++){
if(y[i] > y[j]){
int tmp = y[i];
y[i] = y[j];
y[j] = tmp;
}
int main() {
cin >> n >> m;
int a[n][m];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> a[i][j];
int pr = 1;
if(i % 2 == 0){
pr = 1;
func(a[i]);
pr *= a[i][j];
else{
a[i][j] = pr;
cout << a[i][j] << " ";
cout << endl;
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m;
void func(int y[m]){
for(int i = 0; i < m; i++){
for(int j = i; j < m; j++){
if(y[i] > y[j]){
int tmp = y[i];
y[i] = y[j];
y[j] = tmp;
}
}
}
}
int main() {
cin >> n >> m;
int a[n][m];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> a[i][j];
}
}
int pr = 1;
for(int i = 0; i < n; i++){
if(i % 2 == 0){
pr = 1;
func(a[i]);
for(int j = 0; j < m; j++){
pr *= a[i][j];
}
}
else{
for(int j = 0; j < m; j++){
a[i][j] = pr;
}
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cout << a[i][j] << " ";
}
cout << endl;
}
}