#P1462B. Last Year's Substring
Last Year's Substring
Description
Polycarp has a string of length consisting of decimal digits. Polycarp performs the following operation with the string no more than once (i.e. he can perform operation or time):
- Polycarp selects two numbers and () and removes characters from the string at the positions (i.e. removes substring ). More formally, Polycarp turns the string into the string .
For example, the string "20192020" Polycarp can turn into strings:
- "2020" (in this case or );
- "2019220" (in this case );
- "020" (in this case );
- other operations are also possible, only a few of them are listed above.
Polycarp likes the string "2020" very much, so he is wondering if it is possible to turn the string into a string "2020" in no more than one operation? Note that you can perform zero operations.
The first line contains a positive integer () — number of test cases in the test. Then test cases follow.
The first line of each test case contains an integer () — length of the string . The next line contains a string of length consisting of decimal digits. It is allowed that the string starts with digit 0.
For each test case, output on a separate line:
- "YES" if Polycarp can turn the string into a string "2020" in no more than one operation (i.e. he can perform or operation);
- "NO" otherwise.
You may print every letter of "YES" and "NO" in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).
Input
The first line contains a positive integer () — number of test cases in the test. Then test cases follow.
The first line of each test case contains an integer () — length of the string . The next line contains a string of length consisting of decimal digits. It is allowed that the string starts with digit 0.
Output
For each test case, output on a separate line:
- "YES" if Polycarp can turn the string into a string "2020" in no more than one operation (i.e. he can perform or operation);
- "NO" otherwise.
You may print every letter of "YES" and "NO" in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).
Note
In the first test case, Polycarp could choose and .
In the second test case, Polycarp could choose and .
In the third test case, Polycarp did not perform any operations with the string.