🏑 index : github.com/captn3m0/codechef.git

---
category_name: easy
problem_code: MAKEART
problem_name: Art
languages_supported:
    - ADA
    - ASM
    - BASH
    - BF
    - C
    - 'C99 strict'
    - CAML
    - CLOJ
    - CLPS
    - 'CPP 4.3.2'
    - 'CPP 4.9.2'
    - CPP14
    - CS2
    - D
    - ERL
    - FORT
    - FS
    - GO
    - HASK
    - ICK
    - ICON
    - JAVA
    - JS
    - 'LISP clisp'
    - 'LISP sbcl'
    - LUA
    - NEM
    - NICE
    - NODEJS
    - 'PAS fpc'
    - 'PAS gpc'
    - PERL
    - PERL6
    - PHP
    - PIKE
    - PRLG
    - PYPY
    - PYTH
    - 'PYTH 3.4'
    - RUBY
    - SCALA
    - 'SCM chicken'
    - 'SCM guile'
    - 'SCM qobi'
    - ST
    - TCL
    - TEXT
    - WSPC
max_timelimit: '1'
source_sizelimit: '50000'
problem_author: kevinsogo
problem_tester: 'xcwgf666,antoniuk1'
date_added: 30-05-2016
tags:
    - cakewalk
    - kevinsogo
    - loops
    - snckpa16
editorial_url: 'http://discuss.codechef.com/problems/MAKEART'
time:
    view_start_date: 1465140600
    submit_start_date: 1465140600
    visible_start_date: 1465140600
    end_date: 1735669800
    current: 1493558166
layout: problem
---
All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](/download/translated/SNCKPA16/mandarin/MAKEART.pdf), [Russian](/download/translated/SNCKPA16/russian/MAKEART.pdf) and [Vietnamese](/download/translated/SNCKPA16/vietnamese/MAKEART.pdf) as well.

Chef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only.

Chef's canvas is **N** millimeters long and is initially all white. For simplicity, colors will be represented by an integer between 0 and **105**. 0 indicates white. The picture he is envisioning is also **N** millimeters long and the **i**th millimeter consists purely of the color **Ci**. Unfortunately, his brush isn't fine enough to paint every millimeter one by one. The brush is 3 millimeters wide and so it can only paint three millimeters at a time _with the same color._ Painting over the same place completely replaces the color by the new one. Also, Chef has lots of bottles of paints of each color, so he will never run out of paint of any color.

Chef also doesn't want to ruin the edges of the canvas, so he doesn't want to paint any part beyond the painting. This means, for example, Chef cannot paint just the first millimeter of the canvas, or just the last two millimeters, etc.

Help Chef by telling him whether he can finish the painting or not with these restrictions.

### Input

The first line of the input contains an integer **T** denoting the number of test cases. The description of **T** test cases follows.

The first line of each test case contains a single integer **N**. The second line contains **N** space-separated integers **C1**, **C2**, ..., **CN** denoting the colors of Chef's painting.

### Output

For each test case, output a single line containing either β€œYes” or β€œNo” (without quotes), denoting whether Chef can finish the painting or not.

### Constraints

- **1** ≀ **T** ≀ **105**
- **3** ≀ **N** ≀ **105**
- The sum of the **N**s over all the test cases in a single test file is ≀ **5Γ—105**
- **1** ≀ **Ci** ≀ **105**
 
### Example

 ```
<b>Input:</b>
<tt>3
4
1 5 5 5
4
1 1 1 5
3
5 5 2
</tt>
<b>Output:</b>
<tt>Yes
Yes
No
</tt>
<pre>### Explanation

**Example case 1.** Chef's canvas initially contains the colors \[0,0,0,0\]. Chef can finish the painting by first painting the first three millimeters with color 1, so the colors become \[1,1,1,0\], and then the last three millimeters with color 5 so that it becomes \[1,5,5,5\].

**Example case 2.** Chef's canvas initially contains the colors \[0,0,0,0\]. Chef can finish the painting by first painting the last three millimeters by color 5 so the colors become \[0,5,5,5\], and then the first three millimeters by color 1 so it becomes \[1,1,1,5\].

**Example case 3.** In this test case, Chef can only paint the painting as a whole, so all parts must have the same color, and the task is impossible.