CF2036A.Quintomania

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Quintomania

Boris Notkin composes melodies. He represents them as a sequence of notes, where each note is encoded as an integer from 00 to 127127 inclusive. The interval between two notes aa and bb is equal to ab|a - b| semitones.

Boris considers a melody perfect if the interval between each two adjacent notes is either 55 semitones or 77 semitones.

After composing his latest melodies, he enthusiastically shows you his collection of works. Help Boris Notkin understand whether his melodies are perfect.

Input

The first line contains an integer tt (1t10001 \leq t \leq 1000) — the number of melodies.

Each melody is described by two lines.

The first line contains an integer nn (2n502 \leq n \leq 50) — the number of notes in the melody.

The second line contains nn integers a1,a2,,ana_{1}, a_{2}, \dots, a_{n} (0ai1270 \leq a_{i} \leq 127) — the notes of the melody.

Output

For each melody, output "YES", if it is perfect; otherwise, output "NO".

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Samples

8
2
114 109
2
17 10
3
76 83 88
8
38 45 38 80 85 92 99 106
5
63 58 65 58 65
8
117 124 48 53 48 43 54 49
5
95 102 107 114 121
10
72 77 82 75 70 75 68 75 68 75
YES
YES
YES
NO
YES
NO
YES
YES

在线编程 IDE

建议全屏模式获得最佳体验