def ja;  puts'Yes'; exit end
def nein; puts'No'; exit end

N = gets.to_i
A, B = $<.map{|ln| ln.split.map(&:to_i) }

IA = (0...N).sort_by{|i| A[i] }
IB = (0...N).sort_by{|i| B[i] }
A’ = IA.map{|i| A[i] }
B’ = IB.map{|i| B[i] }

nein unless (0...N).all?{|i| A’[i]<=B’[i]  }

ja if (1...N).any?{|i| A’[i]<=B’[i-1] }

visited, i = [nil]*N, 0
until visited[IA[i]]
	visited[IA[i]] = 1
	i = IB[IA[i]]
end
visited.any?(&:nil?) ? ja : nein
