#include int n; int h[110][110]; int main() { scanf("%d", &n); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { scanf("%d", &h[i][j]); } } for (int i = 0; i < n; ++i) { int li, ri, ui, di; li = 0; ri = 0; ui = 0; di = 0; // li int curheight = 0; for (int j = 0; j < n; ++j) { if (h[i][j] > curheight) { li++; curheight = h[i][j]; } } curheight = 0; for (int j = n - 1; j >= 0; --j) { if (h[i][j] > curheight) { ri++; curheight = h[i][j]; } } curheight = 0; for (int j = 0; j < n; ++j) { if (h[j][i] > curheight) { ui++; curheight = h[j][i]; } } curheight = 0; for (int j = n - 1; j >= 0; --j) { if (h[j][i] > curheight) { di++; curheight = h[j][i]; } } printf("%d %d %d %d\n", li, ri, ui, di); } return 0; }