T = gets.to_i T.times do n = gets.to_i a = gets.split.map(&:to_i) b = gets.split.map(&:to_i) if a[0] != b[0] || a.sort != b.sort puts 'No' else if 2.step(n, 2).all? { |i| i < n / 2 || a[i] == b[i] } puts 'Yes' else puts 'No' end end end