← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	if !scanner.Scan() {
		return
	}
	n, _ := strconv.Atoi(scanner.Text())

	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		for j := 0; j < n; j++ {
			scanner.Scan()
			val, _ := strconv.Atoi(scanner.Text())
			matrix[i][j] = val
		}
	}

	p := make([]int, n)
	for k := 0; k < n; k++ {
		// Hypothesis: the element at index k is n (the maximum value).
		// Since min(n, x) = x for all x < n, the k-th row of the matrix
		// must contain the actual values of the permutation for all other indices.
		
		validPerm := true
		seen := make([]bool, n+1)
		
		p[k] = n
		seen[n] = true
		
		for j := 0; j < n; j++ {
			if j == k {
				continue
			}
			val := matrix[k][j]
			// The values must be a permutation of 1..n-1
			if val < 1 || val >= n || seen[val] {
				validPerm = false
				break
			}
			seen[val] = true
			p[j] = val
		}
		
		if !validPerm {
			continue
		}
		
		// Verify if the constructed permutation p actually generates the matrix A
		consistent := true
		for r := 0; r < n; r++ {
			for c := 0; c < n; c++ {
				if r == c {
					continue
				}
				minVal := p[r]
				if p[c] < minVal {
					minVal = p[c]
				}
				if matrix[r][c] != minVal {
					consistent = false
					break
				}
			}
			if !consistent {
				break
			}
		}
		
		if consistent {
			output := make([]string, n)
			for i := 0; i < n; i++ {
				output[i] = strconv.Itoa(p[i])
			}
			fmt.Println(strings.Join(output, " "))
			return
		}
	}
}
```