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 3.step(n, 2).all? { |i| 2 * i <= n || a[i - 1] == b[i - 1] } puts 'Yes' else puts 'No' end end end