Hidden String

Accepts: 437
Submissions: 2174
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
Problem Description
Today is the 1st anniversary of BestCoder. Soda, the contest manager, gets a string $s$ of length $n$. He wants to find three nonoverlapping substrings $s[l_1..r_1]$, $s[l_2..r_2]$, $s[l_3..r_3]$ that: 1. $1 \le l_1 \le r_1 < l_2 \le r_2 < l_3 \le r_3 \le n$ 2. The concatenation of $s[l_1..r_1]$, $s[l_2..r_2]$, $s[l_3..r_3]$ is "anniversary".
Input
There are multiple test cases. The first line of input contains an integer $T$ $(1 \le T \le 100)$, indicating the number of test cases. For each test case: There's a line containing a string $s$ $(1 \le |s| \le 100)$ consisting of lowercase English letters.
Output
For each test case, output "YES" (without the quotes) if Soda can find such thress substrings, otherwise output "NO" (without the quotes).
Sample Input
2
annivddfdersewwefary
nniversarya
Sample Output
YES
NO