n = gets.chomp.to_i
alist = []
n.times do |ni|
  alist[ni] = []
  alist[ni] = gets.chomp.split.collect{ |item| item.to_i}
end

result = -1

class OneGame
  attr_accessor :mini ,:maxi, :nextlist, :maelist, :code
  def initialize(a,b)
    if(a>=b)
      @mini = b
      @maxi = a
    else
      @mini = a
      @maxi = b
    end
    @nextlist = []
    @maelist = []
    @code = "#{@mini}-#{@maxi}"
  end
  def show()
    p [@code,@maelist,@nextlist]
  end
end

startlist = []
hash = Hash.new(false)
list = []
n.times do |ni|
  mae = "0-0"
  (n-1).times do |nii|
    onegame = OneGame.new(ni+1,alist[ni][nii])
    if hash[onegame.code]
      if hash[mae]
        hash[mae].nextlist << hash[onegame.code]
        hash[onegame.code].maelist <<  hash[mae]
      end
    else
      hash[onegame.code] = onegame
      if hash[mae]
        hash[mae].nextlist << hash[onegame.code]
        hash[onegame.code].maelist << hash[mae]
      end
    end
    mae = onegame.code
  end
end

hash.each do |k,v|
   if v.maelist == []
    startlist << k
  end
end
startlist.each do |key|
  hash[key].nextlist
end

puts result