T = gets.to_i T.times do n = gets.to_i a = gets.split.map(&:to_i) if a[0] == 1 a = a.map { |x| x ^ 1 } end if a[-1] == 1 puts 'Yes' elsif a.each_cons(2).any? { |x, y| x == 1 && y == 1 } puts 'Yes' elsif a.count(1) >= 4 puts 'Yes' else puts 'No' end end