{"extraResources":{"example.01.mu":"TVXzATUNCiFjMTtBDQohYzI7QUJDREVGR0FCQ0RFRkdBQkNERQ0KIWMzO0FER0NGQkVBREdDRkJFQURHQ0YNCiFjNDtBQkVBREdDRkJFQURHQ0ZCRUFEDQohYzU7Q0NHR0FBR0ZGRUVERENHR0ZGRUVCR0dGRkVFQg0K"},"scoring":null,"notes":"","legend":"Your friend Gassassini Pianini is learning to play the piano. He has a piano at home with a standard layout of 88 keys:\r\n\r\n\\begin{center}\r\n\\includegraphics{out-of-bounds-piano_pictures-2.ps}\r\n\\end{center}\r\n\r\nIn this problem, we will only be interested in the 52 white keys. They are named consecutively with the letters of the English alphabet A--G in a cycle of length seven (called an \\textit{octave}), as shown in the image.\r\n\r\nGassassini Pianini has obtained the scores of several musical pieces by the violinist Paganini and wants to transpose them for the piano. For each piece, he has already decoded the musical notation and obtained a string of letters A--G that constitutes the melody. Now he wants to play the pieces on the piano, and he does not care from which octave a particular note is taken: for example, if the string indicates that the next note is A, he will be satisfied with any of the eight A notes available on the piano.\r\n\r\nThe problem is that Gassassini Pianini is still inexperienced and cannot stretch his fingers too wide. He can choose the first note freely (from the available keys with the required letter); however, for each subsequent note, he can only play one that is at most three keys away from the previous one in either direction. For example, suppose the last note played was the dark gray D in the illustration above; then the next note can either be exactly that same D or one of the six light gray notes in its vicinity.\r\n\r\nYou are given string transcriptions of several musical pieces that interest Gassassini Pianini; determine whether he will be able to play them or if he needs to practice finger positioning.","authorLogin":"imp0","language":"english","timeLimit":1000,"output":"For each of the $t$ strings, print ``\\texttt{Yes}'' if Gassassini Pianini can play the piece on the piano, and ``\\texttt{No}'' if it is impossible. Print each answer on a separate line. You may choose the case of the letters you print arbitrarily; in other words, the checking program does not care which of your letters are uppercase and which are lowercase.","inputFile":"stdin","outputFile":"stdout","input":"The first line contains an integer $t$: the number of musical pieces ($1 \\le t \\le 10^4$).\r\n\r\nEach of the following $t$ lines contains a non-empty string $s_i$ of uppercase English letters~\\mbox{A--G}: the transcription of a musical piece. The total number of letters in all transcriptions is at~most~$2 \\cdot 10^5$.","authorName":"Mikhail Ivanov","sampleTests":[{"output":"YES\r\nYes\r\nNO\r\nno\r\nYES\r\n","input":"5\r\nA\r\nABCDEFGABCDEFGABCDE\r\nADGCFBEADGCFBEADGCF\r\nABEADGCFBEADGCFBEAD\r\nCCGGAAGFFEEDDCGGFFEEBGGFFEEB\r\n","inputFile":"example.01","outputFile":"example.01.a"}],"name":"Out of Bounds Piano","interaction":null,"memoryLimit":1073741824,"tutorial":"{\r\n    \\parindent=1cm\r\n    \\begin{tabular}{l@{\\extracolsep{1cm}}l}\r\n         Idea: & Mikhail Ivanov\\\\\r\n         Development: & Mikhail Ivanov\\\\\r\n     \\end{tabular}\r\n}\r\n\r\nImagine that the keyboard is two-sided infinite, and we enumerate its keys with integers. Note that each next key can be uniquely determined by its letter and the previous key. Let us construct the route on this infinite keyboard (starting with any number with proper residue mod 7) and store the reached minimum and maximum. Then, with jumps of seven, let us try to put these minimum and maximum into the segment $[0; 51]$: the answer is ``\\texttt{YES}'' whenever it is possible. To check that, add the minimum number of sevens (possibly negative) such that the minimum is (still) non-negative, and check that the maximum is at most 51."}