#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#include <random>
using namespace std;
using value_t = int;
using row_t = vector<value_t>;
using matrix_t = vector<row_t>;
value_t min_value(const matrix_t& matrix, const size_t column) {
const auto n = matrix.size();
auto min = matrix[0][column];
for (size_t i = 1; i < n; ++i) {
if (matrix[i][column] < min) {
min = matrix[i][column];
}
}
return min;
}
int main() {
cout << "n, m: ";
size_t n, m;
cin >> n >> m;
cout.put('\n');
matrix_t matrix(n, row_t(m));
uniform_int_distribution<> uid(-3, 40);
mt19937 gen{ random_device()() };
for (auto& row : matrix) {
for (auto& value : row) {
value = uid(gen);
cout << setw(4) << value;
}
cout.put('\n');
}
cout.put('\n');
row_t min_values(m);
for (size_t j = 0; j < m; ++j) {
min_values[j] = min_value(matrix, j);
}
for (auto value : min_values) {
cout << setw(4) << value;
}
puts("\n");
const auto it = max_element(begin(min_values), end(min_values));
const auto position = distance(begin(min_values), it) + 1;
cout << "position: " << position << '\n';
}