Polycarp has a string $s[1 \dots n]$ of length $n$ consisting of decimal digits. Polycarp performs the following operation with the string $s$ no more than once (i.e. he can perform operation $0$ or $1$ time):

Polycarp selects two numbers $i$ and $j$ ($1 \leq i \leq j \leq n$) and removes characters from the $s$ string at the positions $i, i+1, i+2, \ldots, j$ (i.e. removes substring $s[i \dots j]$). More formally, Polycarp turns the string $s$ into the string $s_1 s_2 \ldots s_{i-1} s_{j+1} s_{j+2} \ldots s_{n}$.

For example, the string $s = $"20192020" Polycarp can turn into strings:

"2020" (in this case $(i, j)=(3, 6)$ or $(i, j)=(1, 4)$);

"2019220" (in this case $(i, j)=(6, 6)$);

"020" (in this case $(i, j)=(1, 5)$);

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 $s$ into a string "2020" in no more than one operation? Note that you can perform zero operations.


-----Input-----

The first line contains a positive integer $t$ ($1 \leq t \leq 1000 $) — number of test cases in the test. Then $t$ test cases follow.

The first line of each test case contains an integer $n$ ($4 \leq n \leq 200$) — length of the string $s$. The next line contains a string $s$ of length $n$ consisting of decimal digits. It is allowed that the string $s$ starts with digit 0.


-----Output-----

For each test case, output on a separate line:

"YES" if Polycarp can turn the string $s$ into a string "2020" in no more than one operation (i.e. he can perform $0$ or $1$ 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).


-----Examples-----

Input
6
8
20192020
8
22019020
4
2020
5
20002
6
729040
6
200200
Output
YES
YES
YES
NO
NO
NO


-----Note-----

In the first test case, Polycarp could choose $i=3$ and $j=6$.

In the second test case, Polycarp could choose $i=2$ and $j=5$.

In the third test case, Polycarp did not perform any operations with the string.

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Dynamic programming

Implementation


Solutions:
a = int(input())
for i in range(a):
	b = int(input())
	c = input()
	if c[0:4] == '2020':
		print('YES')
	elif c[0:3] == '202' and c[b - 1] == '0':
		print('YES')
	elif c[0:2] == '20' and c[b - 2:b] == '20':
		print('YES')
	elif c[0] == '2' and c[b - 3:b] == '020':
		print('YES')
	elif c[b - 4:b] == '2020':
		print('YES')
	else:
		print('NO')


def is_2020_substring(s):
	return s.startswith('2020') or s.endswith('2020') or (s.startswith('202') and s.endswith('0')) or (s.startswith('20') and s.endswith('20')) or (s.startswith('2') and s.endswith('020'))
for _ in range(int(input())):
	n = int(input())
	s = input()
	print('YES' if is_2020_substring(s) else 'NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	count = 0
	if s[0:0 + 4] == '2020' or s[n - 4:n] == '2020':
		print('YES')
	elif s[0:2] == '20' and s[n - 2:n] == '20':
		print('YES')
	elif s[0:1] == '2' and s[n - 3:n] == '020':
		print('YES')
	elif s[0:3] == '202' and s[n - 1:n] == '0':
		print('YES')
	else:
		print('NO')


import math
import sys
import bisect
from heapq import heapify, heappop, heappush
from itertools import *
from collections import deque, OrderedDict
from pprint import pprint
sys.setrecursionlimit(10 ** 6)
II = lambda : sys.stdin.readline()
inp = lambda : int(II())
inpm = lambda : map(int, II().split())
inpl = lambda : list(inpm())
arr_mn = lambda _n, _m: [[0 for __ in range(_m)] for _ in range(_n)]
arr_nn = lambda _n: arr_mn(_n, _n)
(WHITE, GREY, BLACK, RED) = (0, 1, 2, 3)
EPS = 1e-09
INF = int(1e+18)
MOD = int(1000000000.0) + 7
N = 2000009

def solve():
	n = inp()
	s = input()
	x = '2020'
	for i in range(5):
		if s[:i] == x[:i] and s[-(4 - i):] == x[-(4 - i):] or s[:4] == '2020':
			print('yes')
			return
	print('no')

def main():
	t = inp()
	for i in range(t):
		solve()
main()


def solve(s):
	if '2020' in s[:4] or '2020' in s[-4:]:
		return 'YES'
	for i in range(1, 4):
		if '2020' in s[:4 - i] + s[-i:]:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(0, t):
	n = int(input())
	s = input()
	print(solve(s[:n]))


case = int(input())
for i in range(1, case + 1):
	n = int(input())
	a = input()
	test = False
	if 3 < n < 201:
		if a[0] == a[n - 2] == '2' and a[1] == a[n - 1] == '0':
			test = True
		if a[0] == a[2] == '2' and a[1] == a[3] == '0':
			test = True
		if a[n - 1] == a[n - 3] == '0' and a[n - 2] == a[n - 4] == '2':
			test = True
		if a[0] == a[n - 2] == '2' and a[n - 3] == a[n - 1] == '0':
			test = True
		if a[0] == a[2] == '2' and a[1] == a[n - 1] == '0':
			test = True
	if test == True:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	print('YES' if s[:4] == '2020' or s[-4:] == '2020' or s[:3] + s[-1] == '2020' or (s[:2] + s[-2:] == '2020') or (s[0] + s[-3:] == '2020') else 'NO')


def main():
	tests = int(input())
	for _ in range(tests):
		n = int(input())
		s = input()
		yes = False
		aux = ['2', '0', '2', '0']
		end = -1
		init = 0
		(old_end, old_init) = (-1, -1)
		for _ in range(n):
			(old_end, old_init) = (end, init)
			if s[end] == aux[end]:
				end -= 1
			if s[init] == aux[init]:
				init += 1
			if old_end == end and init == old_init:
				break
			if abs(end) - 1 + init >= 4:
				yes = True
				break
		if yes:
			print('YES')
		else:
			print('NO')
main()


for i in range(int(input())):
	lenn = int(input())
	string = input()
	if string[0:4] == '2020':
		output = 'YES'
	else:
		for i in range(0, 5):
			if string[0:i] + string[-(4 - i):] == '2020':
				output = 'YES'
				break
			else:
				output = 'NO'
	print(output)


import sys
l = sys.stdin.readlines()
t = int(l[0].replace('\n', ''))
i = 2
for _ in range(t):
	s = l[i].replace('\n', '')
	i += 2
	if s == '2020':
		print('YES')
		continue
	if s[-4:] == '2020':
		print('YES')
		continue
	if s[0:4] == '2020':
		print('YES')
		continue
	if s[0] == '2' and s[-3:] == '020':
		print('YES')
		continue
	if s[0:2] == '20' and s[-2:] == '20':
		print('YES')
		continue
	if s[0:3] == '202' and s[-1:] == '0':
		print('YES')
		continue
	print('NO')


test_cases = int(input())
for case in range(test_cases):
	length_of_string = int(input())
	input_string = input()
	if input_string[:4] == '2020':
		print('YES')
	elif input_string[:3] == '202' and input_string[-1:] == '0':
		print('YES')
	elif input_string[:2] == '20' and input_string[-2:] == '20':
		print('YES')
	elif input_string[:1] == '2' and input_string[-3:] == '020':
		print('YES')
	elif input_string[-4:] == '2020':
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	number = input()
	if number[-4:] == '2020' or number[:4] == '2020':
		print('YES')
	elif number[0] == '2' and number[-3:] == '020':
		print('YES')
	elif number[:3] == '202' and number[-1] == '0':
		print('YES')
	elif number[:2] == '20' and number[-2:] == '20':
		print('YES')
	else:
		print('NO')


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, S):
	T = '2020'
	i = 0
	while i < 4 and S[i] == T[i]:
		i += 1
	j = 0
	while j < 4 and S[len(S) - 1 - j] == T[len(T) - 1 - j]:
		j += 1
	if i + j >= 4:
		return 'YES'
	return 'NO'
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	S = input().decode().rstrip()
	ans = solve(N, S)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = len(s)
	if l == n:
		for i in range(5):
			if s[:4 - i] + s[n - i:] == '2020':
				print('yes')
				break
		else:
			print('no')


import sys
T = int(sys.stdin.readline())
for i in range(T):
	N = int(sys.stdin.readline())
	num = str(sys.stdin.readline().strip())
	if '2020' in num[0:4] or '2020' in num[-4:]:
		print('YES')
	elif '20' in num[:2] and '20' in num[-2:]:
		print('YES')
	elif '2' in num[0] and '020' in num[-3:]:
		print('YES')
	elif '202' in num[:3] and '0' in num[-1]:
		print('YES')
	else:
		print('NO')


def newyear(n, s):
	if len(s) == 4 and s == '2020':
		print('YES')
		return None
	temp = -1
	tt = '2020'
	for i in range(4):
		if s[i] != tt[i]:
			break
		temp = i
	if temp == -1:
		temp = 0
	else:
		temp += 1
	tt2 = '0202'
	temp2 = 0
	for i in range(n - 1, n - 1 - 4, -1):
		if s[i] != tt2[temp2]:
			break
		temp2 += 1
	if temp + temp2 >= 4:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	n = int(input())
	number = input().strip()
	newyear(n, number)


def solution():
	x = int(input())
	string = input()
	if x == 4 and string == '2020':
		return 'YES'
	elif string[0] == '2' and string[1] == '0' and (string[2] == '2') and (string[3] == '0') or (string[x - 4] == '2' and string[x - 3] == '0' and (string[x - 2] == '2') and (string[x - 1] == '0')) or (string[0] == '2' and string[1] == '0' and (string[x - 2] == '2') and (string[x - 1] == '0')) or (string[0] == '2' and string[x - 3] == '0' and (string[x - 2] == '2') and (string[x - 1] == '0')) or (string[0] == '2' and string[1] == '0' and (string[2] == '2') and (string[x - 1] == '0')):
		return 'YES'
	else:
		return 'NO'
n = int(input())
for i in range(n):
	print(solution())


t = int(input())
for k in range(t):
	n = int(input())
	s = input()
	k = 0
	if s[0] == '2':
		if s[1] == '0':
			if s[2] == '2':
				if s[3] == '0':
					k = 1
				elif s[n - 1] == '0':
					k = 1
			elif s[n - 2] == '2':
				if s[n - 1] == '0':
					k = 1
		elif s[n - 3] == '0':
			if s[n - 2] == '2':
				if s[n - 1] == '0':
					k = 1
	elif s[n - 4] == '2':
		if s[n - 3] == '0':
			if s[n - 2] == '2':
				if s[n - 1] == '0':
					k = 1
	if k:
		print('YES')
	else:
		print('NO')


t = int(input())
result = []
for i in range(0, t):
	n = int(input())
	a = str(input())
	if a.startswith('2020'):
		result.append('YES')
	elif a.endswith('2020'):
		result.append('YES')
	elif a.startswith('20') and a.endswith('20'):
		result.append('YES')
	elif a.startswith('2') and a.endswith('020'):
		result.append('YES')
	elif a.startswith('202') and a.endswith('0'):
		result.append('YES')
	else:
		result.append('NO')
print('\n'.join(result))


x = int(input())
while x > 0:
	n = int(input())
	s = input()
	if s == '2020':
		print('YES')
	elif s[:4] == '2020':
		print('YES')
	elif s[-4:] == '2020':
		print('YES')
	elif s[:2] + s[-2:] == '2020':
		print('YES')
	elif s[:1] + s[-3:] == '2020':
		print('YES')
	elif s[:3] + s[-1:] == '2020':
		print('YES')
	else:
		print('NO')
	x -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	flag = 'NO'
	if s[0:4] == '2020':
		flag = 'YES'
	elif s[-4:] == '2020':
		flag = 'YES'
	else:
		for i in range(1, 4):
			if s[0:i] + s[i + n - 4:] == '2020':
				flag = 'YES'
	print(flag)


tc = int(input())
for i in range(tc):
	x = int(input())
	y = input()
	if y[0] == '2' and y[1] == '0' and (y[2] == '2') and (y[3] == '0') or (y[0] == '2' and y[1] == '0' and (y[2] == '2') and (y[-1] == '0')) or (y[0] == '2' and y[1] == '0' and (y[-2] == '2') and (y[-1] == '0')) or (y[0] == '2' and y[-3] == '0' and (y[-2] == '2') and (y[-1] == '0')) or (y[-4] == '2' and y[-3] == '0' and (y[-2] == '2') and (y[-1] == '0')):
		print('YES')
	else:
		print('NO')


STR = '2020'
t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	if n < 4:
		print('NO')
	elif a[:4] == STR:
		print('YES')
	elif a[:3] + a[-1:] == STR:
		print('YES')
	elif a[:2] + a[-2:] == STR:
		print('YES')
	elif a[:1] + a[-3:] == STR:
		print('YES')
	elif a[-4:] == STR:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	s = input()
	lst = [s[:4], s[:3] + s[-1], s[:2] + s[-2:], s[0] + s[-3:], s[-4:]]
	if '2020' in lst:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	n = int(input())
	s = input()
	pos = False
	for i in range(5):
		if s[0:i] + s[n - 4 + i:n] == '2020':
			pos = True
			break
	print('YES' if pos else 'NO')


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	s = input()
	if n < 4:
		ans.append('no')
	elif s.startswith('2020') or (s.startswith('202') and s.endswith('0')) or (s.startswith('20') and s.endswith('20')) or (s.startswith('2') and s.endswith('020')) or s.endswith('2020'):
		ans.append('yes')
	else:
		ans.append('no')
for i in ans:
	print(i)


def R():
	return map(int, input().split())

def L():
	return list(map(int, input().split()))

def I():
	return int(input())

def S():
	return str(input())
for _ in range(I()):
	l = I()
	s = S()
	fl = False
	for i in range(5):
		if i - 1 < l and l - 4 + i >= 0 and (s[0:i] + s[l - 4 + i:l] == '2020'):
			print('YES')
			fl = True
			break
	if not fl:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	if a[0] + a[n - 3] + a[n - 2] + a[n - 1] == '2020' or a[0] + a[1] + a[n - 2] + a[n - 1] == '2020' or a[0] + a[1] + a[2] + a[3] == '2020' or (a[0] + a[1] + a[2] + a[n - 1] == '2020') or (a[n - 4] + a[n - 3] + a[n - 2] + a[n - 1] == '2020'):
		print('YES')
	else:
		print('NO')


import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	s = Read.string()
	t = '2020'
	d = 0
	for i in range(4):
		if t[i] == s[i]:
			d += 1
		else:
			break
	for i in range(4):
		if t[3 - i] == s[n - i - 1]:
			d += 1
		else:
			break
	print('YES' if d >= 4 else 'NO')
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


t = int(input())
for _ in range(t):
	(n, s) = (int(input()), input())
	res = 'YES' if s.startswith('2020') or s.endswith('2020') or (s.startswith('202') and s.endswith('0')) or (s.startswith('20') and s.endswith('20')) or (s.startswith('2') and s.endswith('020')) else 'NO'
	print(res)


t = int(input())
while t > 0:
	t -= 1
	a = []
	n = int(input())
	a[:0] = input()
	if a[0] == '2' and a[1] == '0' and (a[2] == '2') and (a[3] == '0'):
		print('YES')
		continue
	if a[0] == '2' and a[1] == '0' and (a[2] == '2') and (a[n - 1] == '0'):
		print('YES')
		continue
	if a[0] == '2' and a[1] == '0' and (a[n - 2] == '2') and (a[n - 1] == '0'):
		print('YES')
		continue
	if a[0] == '2' and a[n - 3] == '0' and (a[n - 2] == '2') and (a[n - 1] == '0'):
		print('YES')
		continue
	if a[n - 4] == '2' and a[n - 3] == '0' and (a[n - 2] == '2') and (a[n - 1] == '0'):
		print('YES')
		continue
	print('NO')


n1 = int(input())
for i in range(n1):
	n = int(input())
	s = input()
	k = -1
	for i in range(5):
		j = 4 - i
		if s[0:i] + s[n - j:] == '2020':
			k = 1
			break
	if k > 0:
		print('YES')
	else:
		print('NO')


from sys import stdin
from sys import stdout
from math import *
for __ in range(int(input())):
	n = int(input())
	s = input()
	ans = 'NO'
	if s[:4] == '2020' or s[n - 4:] == '2020':
		ans = 'YES'
	elif s[0] == '2' and s[n - 3:] == '020':
		ans = 'YES'
	elif s[:2] == '20' and s[n - 2:] == '20':
		ans = 'YES'
	elif s[:3] == '202' and s[-1] == '0':
		ans = 'YES'
	elif s == '2020':
		ans = 'YES'
	print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	if ' '.join(s[:4].split()) == '2020' or ' '.join(s[-5:].split()) == '2020':
		print('YES')
		continue
	f = 0
	for i in range(5):
		if ' '.join(s[:i + 1].split()) + ' '.join(s[i - 4:].split()) == '2020':
			print('YES')
			f = 1
			break
	if f:
		continue
	print('NO')


def acharstring(s, n):
	for i in range(5):
		if s[:i] + s[n - 4 + i:] == '2020':
			print('YES')
			return
	print('NO')
for teste in range(int(input())):
	tamanho = int(input())
	string = input()
	acharstring(string, tamanho)


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s.startswith('2020') or s.endswith('2020') or (s.startswith('2') and s.endswith('020')) or (s.startswith('20') and s.endswith('20')) or (s.startswith('202') and s.endswith('0')):
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	_ = input()
	string = input()
	startswith = string.startswith
	endswith = string.endswith
	if startswith('2020'):
		print('YES')
	elif startswith('202') and endswith('0'):
		print('YES')
	elif startswith('20') and endswith('20'):
		print('YES')
	elif startswith('2') and endswith('020'):
		print('YES')
	elif endswith('2020'):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	idx = [(0, 1, 2, 3), (0, 1, 2, -1), (0, 1, -2, -1), (0, -3, -2, -1), (-4, -3, -2, -1)]
	flag = False
	for id in idx:
		temp = ''
		for _ in id:
			temp += s[_]
		if temp == '2020':
			print('YES')
			flag = True
			break
	if not flag:
		print('NO')


for s in [*open(0)][2::2]:
	print('NYOE S'['2020\n' in [s[:i] + s[i - 5:] for i in range(5)]::2])


t = int(input())
while t:
	n = int(input())
	s = input()
	if s.startswith('2020') or s.endswith('2020') or (s.startswith('2') and s.endswith('020')) or (s.startswith('20') and s.endswith('20')) or (s.startswith('202') and s.endswith('0')):
		print('YES')
	else:
		print('NO')
	t -= 1


y = '2020'
t = int(input())
for i in range(t):
	input()
	s = input()
	if s[:4] == y or s[:1] + s[-3:] == y or s[:2] + s[-2:] == y or (s[:3] + s[-1:] == y) or (s[-4:] == y):
		print('YES')
	else:
		print('NO')


t = int(input())
for x in range(t):
	n = int(input())
	s = input()
	p = 'NO'
	if s[-2:] == '20' and s[:2] == '20':
		p = 'YES'
	if s[-3:] == '020' and s[0] == '2':
		p = 'YES'
	if s[-1] == '0' and s[:3] == '202':
		p = 'YES'
	if s[-4:] == '2020':
		p = 'YES'
	if s[:4] == '2020':
		p = 'YES'
	print(p)


import sys
input = sys.stdin.readline
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip('\r\n')
for _ in range(ri()):
	n = ri()
	s = rs()
	ans = 'Yes'
	if s[:4] == '2020':
		ans = 'Yes'
	elif s[n - 4:] == '2020':
		ans = 'Yes'
	elif s[:2] == '20' and s[n - 2:] == '20':
		ans = 'Yes'
	elif s[:1] == '2' and s[n - 3:] == '020':
		ans = 'Yes'
	elif s[:3] == '202' and s[n - 1:] == '0':
		ans = 'Yes'
	else:
		ans = 'No'
	print(ans)


from math import ceil, e
from math import sqrt, gcd
import sys
alnum = {i: chr(j) for (i, j) in zip(range(1, 27), range(97, 123))}
al = 'abcdefghijklmnopqrstuvwxyz'
q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
for _ in [0] * qi():
	(n,) = q()
	a = input()
	if a.startswith('2020') or a.endswith('2020'):
		print('YES')
	elif a.startswith('20') and a.endswith('20'):
		print('YES')
	elif a.startswith('2') and a.endswith('020'):
		print('YES')
	elif a.startswith('202') and a.endswith('0'):
		print('YES')
	else:
		print('NO')


def solve(n, s):
	if s[0:4] == '2020' or s[n - 4:] == '2020':
		return 'YES'
	if s[0:3] == '202' and s[n - 1] == '0':
		return 'YES'
	if s[0:2] == '20' and s[n - 2:] == '20':
		return 'YES'
	if s[0] == '2' and s[n - 3:] == '020':
		return 'YES'
	return 'NO'
t = int(input())
while t:
	n = int(input())
	s = input()
	print(solve(n, s))
	t -= 1


n = int(input())
for i in range(n):
	q = int(input())
	s = input()
	n = len(s)
	if s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[3] == '0'):
		print('YES')
	elif s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[-1] == '0'):
		print('YES')
	elif s[0] == '2' and s[1] == '0' and (s[n - 2] == '2') and (s[n - 1] == '0'):
		print('YES')
	elif s[0] == '2' and s[n - 3] == '0' and (s[n - 2] == '2') and (s[n - 1] == '0'):
		print('YES')
	elif s[n - 4] == '2' and s[n - 3] == '0' and (s[n - 2] == '2') and (s[n - 1] == '0'):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	string = input()
	result = False
	two = False
	if string[0:4] == '2020' or string[-4:] == '2020':
		result = True
	elif string[0:2] == '20' and string[-2:] == '20':
		result = True
	elif string[0] == '2' and string[-3:] == '020':
		result = True
	elif string[0:3] == '202' and string[-1] == '0':
		result = True
	if result:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	ans = 'NO'
	substring = n - 4
	for i in range(5):
		if s[:i] + s[i + substring:] == '2020':
			ans = 'YES'
			break
	print(ans)


import sys
from functools import reduce
from collections import Counter
import time
import datetime
import math

def ip():
	return int(sys.stdin.readline())

def sip():
	return input()

def mip():
	return map(int, sys.stdin.readline().split())

def mips():
	return map(str, sys.stdin.readline().split())

def lip():
	return list(map(int, sys.stdin.readline().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.insert(i, arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
t = ip()
while t:
	t -= 1
	n = ip()
	s = sip()
	if s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[3] == '0'):
		print('YES')
	elif s[-1] == '0' and s[-2] == '2' and (s[-3] == '0') and (s[-4] == '2'):
		print('YES')
	elif s[0] == '2' and s[-1] == '0' and (s[-2] == '2') and (s[-3] == '0'):
		print('YES')
	elif s[0] == '2' and s[1] == '0' and (s[-1] == '0') and (s[-2] == '2'):
		print('YES')
	elif s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[-1] == '0'):
		print('YES')
	else:
		print('NO')


t = int(input())
ans = ''
for i in range(t):
	n = int(input())
	s = input()
	if s[:4] == '2020':
		ans += 'yes \n'
	elif s[:3] == '202' and s[n - 1] == '0':
		ans += 'yes \n'
	elif s[:2] == '20' and s[n - 2:] == '20':
		ans += 'yes \n'
	elif s[0] == '2' and s[n - 3:] == '020':
		ans += 'yes \n'
	elif s[n - 4:] == '2020':
		ans += 'yes \n'
	else:
		ans += 'no \n'
print(ans)


for i in range(int(input())):
	n = int(input())
	s = str(input())
	if s[0:4] == '2020' or s[-1:-5:-1] == '0202' or (s[0:2] == '20' and s[-1:-3:-1] == '02'):
		print('YES')
	elif s[0] == '2' and s[-1:-4:-1] == '020' or (s[0:3] == '202' and s[-1] == '0'):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input().strip()
	g = []
	for i in range(5):
		g += [s[0:4 - i] + s[n - i:n]]
	print('YNEOS'['2020' not in g::2])


def solve():
	n = int(input())
	s = input()
	target = '2020'
	if s[:4] == '2020' or s[-4:] == '2020':
		print('YES')
	else:
		for i in range(4):
			if s[:i] == target[:i] and s[i - 4:] == target[i - 4:]:
				print('YES')
				return
		print('NO')

def main():
	t = int(input())
	for i in range(t):
		solve()
main()


t = int(input())
for j in range(t):
	tmp = 0
	n = int(input())
	s = input()
	p = True
	if s[n - 1] == '0' and p:
		tmp += 1
	else:
		p = False
	if s[n - 2] == '2' and p:
		tmp += 1
	else:
		p = False
	if s[n - 3] == '0' and p:
		tmp += 1
	else:
		p = False
	if s[n - 4] == '2' and p:
		tmp += 1
	else:
		p = False
	if tmp == 4:
		print('YES')
		continue
	else:
		p = True
		if s[0] == '2' and p:
			tmp += 1
		else:
			p = False
		if s[1] == '0' and p and (tmp < 4):
			tmp += 1
		else:
			p = False
		if s[2] == '2' and p and (tmp < 4):
			tmp += 1
		else:
			p = False
		if s[3] == '0' and p and (tmp < 4):
			tmp += 1
		else:
			p = False
	if tmp == 4:
		print('YES')
	else:
		print('NO')


T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	if s == '2020' or s[:4] == '2020' or s[-4:] == '2020':
		print('YES')
	else:
		lst = [('2', '020'), ('20', '20'), ('202', '0')]
		if s[0] == '2' and s[-3:] == '020' or (s[:2] == '20' and s[-2:] == '20') or (s[:3] == '202' and s[-1:] == '0'):
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	x = '2020'
	ans = [0] * 4
	a = 0
	b = n - 1
	for p in range(4):
		if s[p] == x[p]:
			ans[p] = 1
		else:
			break
	for p in range(4):
		if s[b] == x[3 - p]:
			ans[3 - p] = 1
		else:
			break
		b -= 1
	print('YES' if sum(ans) == 4 else 'NO')


from collections import defaultdict
import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	s = list(input())
	last = 0
	first = 0
	if s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[3] == '0'):
		last = 1
		first = 1
	if s[-1] == '0' and s[-2] == '2' and (s[-3] == '0') and (s[-4] == '2'):
		last = 1
		first = 1
	if s[0] == '2' and s[-1] == '0' and (s[-2] == '2') and (s[-3] == '0'):
		last = 1
		first = 1
	if s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[-1] == '0'):
		first = 1
		last = 1
	if s[0] == '2' and s[1] == '0' and (s[-2] == '2') and (s[-1] == '0'):
		first = 1
		last = 1
	if first == 1 and last == 1:
		print('YES')
	else:
		print('NO')


num_tests = int(input())
for _ in range(num_tests):
	__ = input()
	s = input()
	if s[:4] == '2020':
		print('YES')
	elif s[:3] == '202' and s[-1] == '0':
		print('YES')
	elif s[:2] == '20' and s[-2:] == '20':
		print('YES')
	elif s[:1] == '2' and s[-3:] == '020':
		print('YES')
	elif s[-4:] == '2020':
		print('YES')
	else:
		print('NO')


for ii in range(int(input())):
	n = int(input())
	s = input()
	if n < 4:
		print('NO')
		continue
	flag = 0
	if s[0:4] == '2020':
		flag = 1
	if s[0] == '2' and s[-3:] == '020':
		flag = 1
	if s[0:2] == '20' and s[-2:] == '20':
		flag = 1
	if s[0:3] == '202' and s[-1] == '0':
		flag = 1
	if s[-4:] == '2020':
		flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


import time, math as mt, bisect as bs, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def readTree(n, e):
	adj = [set() for i in range(n + 1)]
	for i in range(e):
		(u1, u2) = IP()
		adj[u1].add(u2)
	return adj

def sieve():
	li = [True] * (10 ** 3 + 5)
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	(prime, cur) = ([0] * 200, 0)
	for i in range(10 ** 3 + 5):
		if li[i] == True:
			prime[cur] = i
			cur += 1
	return prime

def SPF():
	mx = 10 ** 6 + 1
	spf[1] = 1
	for i in range(2, mx):
		if spf[i] == 1000000000.0:
			spf[i] = i
			for j in range(i * i, mx, i):
				if i < spf[j]:
					spf[j] = i
	return

def prime(n, d):
	prm = set()
	while n != 1:
		prm.add(spf[n])
		n = n // spf[n]
	for ele in prm:
		d[ele] = d.get(ele, 0) + 1
	return
mod = 998244353

def solve():
	n = II()
	s = stdin.readline()
	s = s[:n]
	if s[0] == '2' and s[1] == '0' and (s[-2] == '2') and (s[-1] == '0'):
		print('YES')
		return
	elif s[0] == '2' and s[-3] == '0' and (s[-2] == '2') and (s[-1] == '0'):
		print('YES')
		return
	elif s[-4] == '2' and s[-3] == '0' and (s[-2] == '2') and (s[-1] == '0'):
		print('YES')
		return
	elif s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[-1] == '0'):
		print('YES')
		return
	elif s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[3] == '0'):
		print('YES')
		return
	print('NO')
	return
t = II()
for i in range(t):
	solve()


t = int(input())
for i in range(t):
	l = int(input())
	s = str(input())
	if s[0:4] == '2020' or s[-4:] == '2020':
		print('YES')
	elif s[0] == '2' and s[-3:] == '020' or (s[-1] == '0' and s[0:3] == '202'):
		print('YES')
	elif s[0:2] == '20' and s[-2:] == '20':
		print('YES')
	else:
		print('NO')


n = int(input(''))
for i in range(n):
	a = int(input(''))
	t = input('')
	if t[0] + t[1] + t[2] + t[3] == '2020' or t[len(t) - 4] + t[len(t) - 3] + t[len(t) - 2] + t[len(t) - 1] == '2020':
		print('YES')
	else:
		t1 = ''
		d = '2020'
		for i in range(4):
			if t[i] == d[i]:
				t1 += d[i]
			else:
				break
		if t1 + t[a - (4 - len(t1)):] == '2020':
			print('YES')
		else:
			print('NO')


import sys, io, os, math
from math import ceil, log

def printlist(n):
	sys.stdout.write(' '.join(map(str, n)) + '\n')

def printf(n):
	sys.stdout.write(str(n) + '\n')

def printns(n):
	sys.stdout.write(str(n))

def intinp():
	return int(sys.stdin.readline())

def strinp():
	return sys.stdin.readline()

def arrinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def mulinp():
	return map(int, sys.stdin.readline().strip().split())

def flush():
	return stdout.flush()

def power_two(x):
	return 1 << x

def solve():
	n = intinp()
	s = input()
	if s[-1] == '0' and s[-2] == '2' and (s[-3] == '0') and (s[-4] == '2'):
		print('YES')
		return
	if s[0] == '2' and s[-1] == '0' and (s[-2] == '2') and (s[-3] == '0'):
		print('YES')
		return
	if s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[3] == '0'):
		print('YES')
		return
	if s[0] == '2' and s[1] == '0' and (s[-2] == '2') and (s[-1] == '0'):
		print('YES')
		return
	if s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[-1] == '0'):
		print('YES')
		return
	else:
		print('NO')
		return

def main():
	tc = intinp()
	for _ in range(0, tc):
		solve()
main()


_ = ['NYOE S'['2020\n' in [j[:i] + j[i - 5:] for i in range(5)]::2] for j in [*open(0)][2::2]]
for i in _:
	print(i)


for _ in range(int(input())):
	length = int(input())
	A = input()
	string = '2020'
	if A[0:4] == '2020' or A[length - 4:length] == '2020' or A[0] + A[1] + A[-2] + A[-1] == '2020' or (A[0] + A[-3] + A[-2] + A[-1] == '2020') or (A[0] + A[1] + A[2] + A[-1] == '2020') or (A[0] + A[-3] + A[-2] + A[-1] == '2020'):
		print('YES')
	else:
		print('NO')


t = int(input())
i = 0
while i < t:
	n = int(input())
	s = input()
	i += 1
	if s[n - 4:] == '2020' or s[0:4] == '2020':
		print('YES')
		continue
	if s[0] == '2' and s[n - 3:] == '020':
		print('YES')
		continue
	if s[0:2] == '20' and s[n - 2:] == '20':
		print('YES')
		continue
	if s[0:3] == '202' and s[n - 1:] == '0':
		print('YES')
		continue
	print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	p = 0
	if (s[n - 3:n - 1] == '02' or (s[1] == '0' and s[-2] == '2') or s[1:3] == '02') and (s[0] == '2' and s[-1] == '0'):
		print('YES')
	elif s[:4] == '2020' or s[n - 4:] == '2020':
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s[n - 4:n] == '2020':
		print('Yes')
	elif s[0] + s[n - 3:n] == '2020':
		print('Yes')
	elif s[0:2] + s[n - 2:n] == '2020':
		print('Yes')
	elif s[0:3] + s[n - 1:n] == '2020':
		print('Yes')
	elif s[0:4] == '2020':
		print('Yes')
	else:
		print('NO')


t = int(input())
for _ in range(0, t):
	n = int(input())
	s = str(input())
	s1 = s[0] + s[-3:]
	flag = False
	if s1 == '2020':
		flag = True
	s1 = s[:2] + s[-2:]
	if s1 == '2020':
		flag = True
	s1 = s[:3] + s[-1:]
	if s1 == '2020':
		flag = True
	s1 = s[:4]
	if s1 == '2020':
		flag = True
	s1 = s[-4:]
	if s1 == '2020':
		flag = True
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	ss = '2020'
	i = 0
	while i < 4 and s[i] == ss[i]:
		i += 1
	if s.endswith(ss[i:]):
		print('YES')
	else:
		print('NO')


for x in range(int(input())):
	n = int(input())
	s = input()
	if s[0] + s[1] + s[2] + s[3] == '2020':
		print('YES')
	elif s[0] + s[1] + s[2] + s[n - 1] == '2020':
		print('YES')
	elif s[0] + s[1] + s[n - 2] + s[n - 1] == '2020':
		print('YES')
	elif s[0] + s[n - 3] + s[n - 2] + s[n - 1] == '2020':
		print('YES')
	elif s[n - 4] + s[n - 3] + s[n - 2] + s[n - 1] == '2020':
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	flag = 0
	if s[0] == '2' and s[n - 1] == '0' and (s[n - 2] == '2') and (s[n - 3] == '0'):
		flag = 1
	if s[0] == '2' and s[n - 1] == '0' and (s[n - 2] == '2') and (s[1] == '0'):
		flag = 1
	if s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[n - 1] == '0'):
		flag = 1
	if s[0] == '2' and s[3] == '0' and (s[2] == '2') and (s[1] == '0'):
		flag = 1
	if s[n - 4] == '2' and s[n - 1] == '0' and (s[n - 2] == '2') and (s[n - 3] == '0'):
		flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


def decision():
	ln = int(input())
	s = input()
	for i in range(ln):
		if s[0] == '2' and s[ln - 3:] == '020':
			print('yes')
			break
		if s[:4] == '2020' or s[ln - 4:] == '2020':
			print('yes')
			break
		if s[:2] == '20' and s[ln - 2:] == '20':
			print('yes')
			break
		if s[:3] == '202' and s[-1] == '0':
			print('yes')
			break
	else:
		print('NO')
test = int(input())
for _ in range(test):
	decision()


t = int(input())
tmp = []
for i in range(t):
	n = int(input())
	s = input()
	if n == 4:
		if s == '2020':
			tmp.append(1)
		else:
			tmp.append(0)
	elif s[-4:] == '2020' or (s[0] == '2' and s[-3:] == '020') or (s[0:2] == '20' and s[-2:] == '20') or (s[0:3] == '202' and s[-1] == '0') or (s[0:4] == '2020'):
		tmp.append(1)
	else:
		tmp.append(0)
for e in tmp:
	if e:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = input()
	for i in range(5):
		if a[0:i] + a[n - (4 - i):n] == '2020':
			print('YES')
			break
	else:
		print('No')


from sys import stdin, stdout
outputs = []
t = int(stdin.readline().strip())
for __ in range(int(t)):
	n = int(stdin.readline().strip())
	a = stdin.readline().strip()
	condn = False
	if a[0:4] == '2020':
		condn = True
	elif a[-4:] == '2020':
		condn = True
	elif a[0] == '2' and a[-3:] == '020':
		condn = True
	elif a[-1] == '0' and a[0:3] == '202':
		condn = True
	elif a[0:2] == '20' and a[-2:] == '20':
		condn = True
	if condn:
		outputs.append('YES')
	else:
		outputs.append('NO')
for output in outputs:
	stdout.write(output + '\n')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if s[0:4] == '2020':
		print('YES')
		continue
	elif s[-4:] == '2020':
		print('YES')
		continue
	elif s[0:3] == '202':
		if s[-1] == '0':
			print('YES')
			continue
	elif s[-3:] == '020' and s[0] == '2':
		print('YES')
		continue
	elif s[0:2] == '20':
		if s[-2:] == '20':
			print('YES')
			continue
	print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	count = 'NO'
	string = n - 4
	for i in range(5):
		if s[:i] + s[i + string:] == '2020':
			count = 'YES'
	print(count)


nt = int(input())
for t in range(nt):
	n = int(input())
	s = input()
	t = '2020'
	yes = 0
	for i in range(4, -1, -1):
		if i == 0:
			if s[:4 - i] == t[:4 - i]:
				print('YES')
				yes = 1
				break
		elif i != 0:
			if s[:4 - i] + s[-i:] == t[:4 - i] + t[-i:]:
				print('YES')
				yes = 1
				break
	if not yes:
		print('NO')


def f(str1, l):
	k = l - 4
	for i in range(l - k + 1):
		if str1[:i] + str1[k + i:] == '2020':
			return True
	return False
n = int(input())
for i in range(n):
	le = int(input())
	print('YES' if f(input(), le) else 'NO')


import sys

def main():

	def analyser(s, n):
		mot = ['2', '0', '2', '0']
		for a in range(5):
			if s[0:a] + s[n - (4 - a):n] == mot:
				return 'YES \n'
		return 'NO \n'
	t = int(sys.stdin.readline())
	for _ in range(t):
		n = int(sys.stdin.readline())
		s = list(sys.stdin.readline())
		sys.stdout.write(analyser(s, n))
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	y = 0
	if s == '2020':
		y = 1
	if s[n - 4:] == '2020' or s[:4] == '2020':
		y = 1
	if s[0] == '2' and s[n - 3:] == '020':
		y = 1
	if s[:2] == '20' and s[n - 2:] == '20':
		y = 1
	if s[:3] == '202' and s[-1] == '0':
		y = 1
	if y == 1:
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	req = '2020'
	count = 0
	for i in range(4):
		if s[i] == req[i]:
			count += 1
		else:
			break
	if s[n - (4 - count):n] == req[count:4]:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = input()
	if a == '2020':
		print('YES')
	else:
		flag = 0
		if a.startswith('2') and a.endswith('020') or (a.startswith('20') and a.endswith('20')) or (a.startswith('202') and a.endswith('0')) or a.startswith('2020') or a.endswith('2020'):
			flag = 1
		if flag == 1:
			print('YES')
		else:
			print('NO')


test = int(input())
for kl in range(test):
	l = int(input())
	x = input()
	if x[0] == '2' and x[len(x) - 1] == '0' and (x[len(x) - 2] == '2') and (x[len(x) - 3] == '0'):
		print('YES')
	elif x[0] == '2' and x[1] == '0' and (x[len(x) - 1] == '0') and (x[len(x) - 2] == '2'):
		print('YES')
	elif x[0] == '2' and x[1] == '0' and (x[2] == '2') and (x[len(x) - 1] == '0'):
		print('YES')
	elif x[0] == '2' and x[1] == '0' and (x[2] == '2') and (x[3] == '0') or (x[len(x) - 1] == '0' and x[len(x) - 2] == '2' and (x[len(x) - 3] == '0') and (x[len(x) - 4] == '2')):
		print('YES')
	else:
		print('NO')


def sol(arr):
	target = '2020'
	if arr[:4] == target:
		return True
	elif arr[:1] + arr[-3:] == target:
		return True
	elif arr[:2] + arr[-2:] == target:
		return True
	elif arr[:3] + arr[-1:] == target:
		return True
	elif arr[-4:] == target:
		return True
	return False
t = int(input())
for _ in range(t):
	n = int(input())
	arr = input()
	if sol(arr):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	possible = False
	for i in range(5):
		if s[:i] + s[n - 4 + i:] == '2020':
			possible = True
	print('YES') if possible else print('NO')


n = int(input())
for i in range(n):
	a = int(input())
	b = input()
	for i in range(5):
		ss = b[0:i] + b[a - 4 + i:a]
		if ss == '2020':
			print('YES')
			break
	else:
		print('NO')


import sys
input = sys.stdin.readline

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def main():
	for _ in range(int(input())):
		n = int(input())
		s = input()
		if n < 4:
			print('NO')
			continue
		a = '2020'
		k = 0
		for i in range(n):
			if k > 3:
				break
			if a[k] == s[i]:
				k += 1
			else:
				break
		if k <= 3:
			rem = 4 - k
			if s[n - rem:n] == a[k:4]:
				print('YES')
			else:
				print('NO')
		else:
			print('YES')
	return
main()


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	sub_str = '2020'
	s1 = s[:1] + s[-3:]
	s2 = s[:2] + s[-2:]
	s3 = s[:3] + s[-1:]
	s4 = s[:4]
	s5 = s[-4:]
	if s1 == '2020' or s2 == '2020' or s3 == '2020' or (s4 == '2020') or (s5 == '2020'):
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in [0] * int(input()):
	input()
	k = input()
	print('NYOE S'['2020' in [k[:4], k[:3] + k[-1], k[:2] + k[-2:], k[0] + k[-3:], k[-4:]]::2])


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s.count('2') < 2 or s.count('0') < 2:
		print('NO')
	else:
		cntr = 0
		for i in range(n):
			for j in range(n):
				res = s[:i] + s[j + 1:]
				if res == '2020':
					cntr += 1
		if cntr == 0:
			print('NO')
		else:
			print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	s = str(input())
	if s == '2020':
		print('YES')
		continue
	m = len(s) - 4
	flag = False
	for i in range(n - m + 1):
		t = s[0:i] + s[i + m:]
		if t == '2020':
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	x = int(input())
	s = str(input())
	if s[0] + s[-3:] == '2020':
		print('yes')
	elif s[:2] + s[-2:] == '2020':
		print('yes')
	elif s[:3] + s[-1] == '2020':
		print('yes')
	elif s[-4:] == '2020':
		print('yes')
	elif s[:4] == '2020':
		print('yes')
	else:
		print('no')


T = int(input())
for _ in range(T):
	n = int(input())
	s = input()
	s1 = s[:4]
	s2 = s[-4:]
	if s1 == '2020' or s2 == '2020':
		print('YES')
		continue
	for i in range(4):
		s3 = s1[:i] + s2[i:]
		if s3 == '2020':
			print('YES')
			break
	else:
		print('NO')


from sys import stdin
inp = stdin.read()
lst = inp.split()
t = lst[0]
s = 1
while s in range(len(lst) - 1):
	n = int(lst[s])
	seq = lst[s + 1]
	s += 2
	if seq.find('2020') == 0 or seq.rfind('2020') == n - 4:
		print('YES')
	elif seq.find('202') == 0 and seq.rfind('0') == n - 1:
		print('YES')
	elif seq.find('2') == 0 and seq.rfind('020') == n - 3:
		print('YES')
	elif seq.find('20') == 0 and seq.rfind('20') == n - 2:
		print('YES')
	else:
		print('NO')


import sys
N = int(200000.0 + 5)
sys.setrecursionlimit(N)

def charming():
	n = int(input())
	s = input()
	for i in range(5):
		ns = s[0:i] + s[n - (4 - i):n]
		if ns == '2020':
			print('YES')
			return
	print('NO')
for t in range(int(input())):
	charming()


t = int(input())
for _ in range(t):
	(n, s) = (int(input()), input())
	yes = s[:4] == '2020'
	for i in range(0, 4):
		if s[:i] + s[-4 + i:] == '2020':
			yes = True
			break
	if yes:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	n = int(input())
	string = input()
	ans = False
	for i in range(0, 5):
		if string[0:i] + string[n - 4 + i:] == '2020':
			ans = True
			break
	if ans:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	t = True
	if s == '2020':
		t = False
	else:
		for i in range(n):
			j = i + n - 4
			x = s[:i] + s[j:]
			if x == '2020':
				t = False
				break
	if t:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	s = str(input())
	remove_digits = n - 4
	for ind in range(5):
		if s[:ind] + s[ind + remove_digits:] == '2020':
			print('YES')
			break
		elif ind == 4:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = '2020'
	for i in range(5):
		if s.startswith(a[:i]) and s.endswith(a[i:]):
			print('YES')
			break
	else:
		print('NO')


def yes():
	print('YES')

def no():
	print('NO')

def solve():
	n = int(input())
	s = input()
	if n < 4:
		no()
	elif s[0:2] == '20' and s[n - 2:n] == '20':
		yes()
	elif s[:1] == '2' and s[n - 3:n] == '020':
		yes()
	elif s[:3] == '202' and s[-1] == '0':
		yes()
	elif s[n - 4:n] == '2020':
		yes()
	elif s[:4] == '2020':
		yes()
	else:
		no()
for testcase in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	b = 'NO'
	if s[:4] == '2020' or s[-4:] == '2020':
		b = 'YES'
	else:
		for i in range(1, 4):
			if s[:i] + s[i + n - 4:] == '2020':
				b = 'YES'
	print(b)


def solve(n, s):
	if n < 4:
		return False
	if s == '2020':
		return True
	if s[:2] == '20' and s[-2:] == '20':
		return True
	if s[0] == '2' and s[-3:] == '020':
		return True
	if s[:3] == '202' and s[-1] == '0':
		return True
	if s[:4] == '2020' or s[-4:] == '2020':
		return True
	return False
T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	result = solve(n, s)
	print('YES' if result else 'NO')


while True:
	try:
		t = eval(input())
		for i in range(t):
			n = eval(input())
			str0 = input()
			if str0[0] == '2' and str0[1] == '0' and (str0[2] == '2') and (str0[3] == '0'):
				print('YES')
			elif str0[0] == '2' and str0[n - 3] == '0' and (str0[n - 2] == '2') and (str0[n - 1] == '0'):
				print('YES')
			elif str0[0] == '2' and str0[1] == '0' and (str0[n - 2] == '2') and (str0[n - 1] == '0'):
				print('YES')
			elif str0[0] == '2' and str0[1] == '0' and (str0[2] == '2') and (str0[n - 1] == '0'):
				print('YES')
			elif str0[n - 4] == '2' and str0[n - 3] == '0' and (str0[n - 2] == '2') and (str0[n - 1] == '0'):
				print('YES')
			else:
				print('NO')
	except:
		break


def main():
	tests = int(input())
	for _ in range(tests):
		s_len = int(input())
		s = input()
		if s[0] == '2' and s[s_len - 3:] == '020':
			print('YES')
			continue
		if s[:2] == '20' and s[s_len - 2:] == '20':
			print('YES')
			continue
		if s[:3] == '202' and s[s_len - 1] == '0':
			print('YES')
			continue
		if s[:4] == '2020' or s[s_len - 4:] == '2020':
			print('YES')
			continue
		print('NO')
main()


def solve():
	n = int(input())
	s = input()
	if s[:4] == '2020':
		return True
	if s[:3] + s[n - 1] == '2020':
		return True
	if s[:2] + s[n - 2:n] == '2020':
		return True
	if s[:1] + s[n - 3:n] == '2020':
		return True
	if s[n - 4:n] == '2020':
		return True
	return False
for _ in range(int(input())):
	if solve():
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	l = len(s)
	if s[0:4] == '2020' or s[-4:] == '2020' or s[:] == '2020' or (s[0:2] == '20' and s[-2:] == '20') or (s[0] == '2' and s[-3:] == '020') or (s[0:3] == '202' and s[-1] == '0'):
		print('YES')
	else:
		print('NO')
	t -= 1


for sd in range(int(input())):
	x = input()
	b = input()
	if b == '2020':
		print('YES')
	elif b[0] + b[1] + b[2] + b[3] == '2020':
		print('YES')
	elif b[-4] + b[-3] + b[-2] + b[-1] == '2020':
		print('YES')
	elif b[0] == '2' and b[-3] + b[-2] + b[-1] == '020':
		print('YES')
	elif b[0] + b[1] == '20' and b[-2] + b[-1] == '20':
		print('YES')
	elif b[0] + b[1] + b[2] == '202' and b[-1] == '0':
		print('YES')
	else:
		print('NO')


test = int(input())
for sdfas in range(test):
	n = int(input())
	a = input()
	if a[:4] == '2020' or a[-4:] == '2020':
		print('YES')
	elif a[:3] == '202' and a[-1] == '0':
		print('YES')
	elif a[:2] == '20' and a[-2:] == '20':
		print('YES')
	elif a[:1] == '2' and a[-3:] == '020':
		print('YES')
	else:
		print('NO')


def testcase():
	n = int(input())
	s = input()
	ans = 'NO'
	if s == '2020':
		ans = 'YES'
	else:
		ns = s[:4]
		if ns == '2020':
			ans = 'YES'
		ns = s[:3] + s[-1:]
		if ns == '2020':
			ans = 'YES'
		ns = s[:2] + s[-2:]
		if ns == '2020':
			ans = 'YES'
		ns = s[:1] + s[-3:]
		if ns == '2020':
			ans = 'YES'
		ns = s[-4:]
		if ns == '2020':
			ans = 'YES'
	print(ans)
	return
import sys, os
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
sys.setrecursionlimit(10 ** 5)
t = int(input())
for _ in range(t):
	testcase()


for i in range(int(input())):
	(string_length, string) = (int(input()), input())
	for (first_slice_end, second_slice_start) in enumerate(range(string_length - 4, string_length + 1)):
		if string[:first_slice_end] + string[second_slice_start:] == '2020':
			print('YES')
			break
	else:
		print('NO')


import math

def func(a):
	n = len(a)
	k = 0
	x = '2020'
	for i in range(n):
		if k < 4 and a[i] == x[k]:
			k += 1
		else:
			break
	v = 3
	for j in range(n - 1, -1, -1):
		if v >= 0 and a[j] == x[v]:
			v -= 1
		else:
			break
	if k > v:
		return 'YES'
	else:
		return 'NO'
q = int(input())
for _ in range(q):
	n = int(input())
	a = input()
	print(func(a))


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	req = '2020'
	f = False
	if n < 4:
		pritn('no')
	else:
		for i in range(4):
			if s[0:i] == req[0:i] and s[-1 * (4 - i):] == req[i:]:
				print('yes')
				f = True
				break
		if s[0:4] == '2020' and f == False:
			f = True
			print('yes')
	if f == False:
		print('no')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	index = 0
	a = '2020'
	for i in range(n):
		if s[i] == a[index]:
			index += 1
		else:
			break
		if index == 4:
			break
	if index == 4:
		print('YES')
	elif s[n - (4 - index):n] == a[index:4]:
		print('YES')
	else:
		print('NO')


cases = int(input())

def solve(s):
	arr = [s[:4], s[-4:], s[:1] + s[-3:], s[:2] + s[-2:], s[:3] + s[-1:]]
	return 'YES' if '2020' in arr else 'NO'
for _ in range(cases):
	n = int(input())
	print(solve(input()))


import math, sys, itertools
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
for t in [wtf[i:i + 2] for i in range(1, len(wtf), 2)]:
	n = int(t[0])
	s = t[1]
	if s[0:4] == '2020':
		print('YES')
	elif s[-4:] == '2020':
		print('YES')
	elif s[0:2] == '20' and s[-2:] == '20':
		print('YES')
	elif s[0] == '2' and s[-3:] == '020':
		print('YES')
	elif s[0:3] == '202' and s[-1] == '0':
		print('YES')
	else:
		print('NO')


S = '2020'
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	flag = False
	for i in range(5):
		if s[:i] + s[n - 4 + i:n] == S:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	num = input()
	for i in range(5):
		if num[0:i] + num[n - 4 + i:n] == '2020':
			print('YES')
			break
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	if s == '2020':
		print('YES')
	else:
		found = 0
		for i in range(n):
			for j in range(i, n):
				str = s[:i] + s[j + 1:]
				if str == '2020':
					print('YES')
					found = 1
					break
			if found == 1:
				break
		if found == 0:
			print('NO')


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input()
		if s[:4] == '2020' or (s[:3] == '202' and s[-1] == '0') or (s[:2] == '20' and s[-2:] == '20') or (s[0] == '2' and s[-3:] == '020') or (s[-4:] == '2020'):
			print('Yes')
		else:
			print('No')
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	flag = -1
	if s[0] == '2':
		flag = 3
		if s[1] == '0':
			flag = 2
			if s[2] == '2':
				flag = 1
				if s[3] == '0':
					flag = 0
	if flag == -1:
		if s[n - 4:] == '2020':
			print('YES')
		else:
			print('NO')
	else:
		temp = '2020'
		if flag == 0:
			print('YES')
		elif s[n - flag:] == temp[4 - flag:]:
			print('YES')
		else:
			print('NO')


def func(s):
	if s[0] == '2' and s[1] == '0' and (s[2] == '2') and (s[3] == '0'):
		return 'YES'
	if s[-1] == '0' and s[-2] == '2' and (s[-3] == '0') and (s[-4] == '2'):
		return 'YES'
	n = len(s)
	i = 0
	j = 0
	string = '2020'
	for x in range(0, 4):
		if s[x] == string[x]:
			i += 1
		else:
			break
	for x in range(n - 1, n - 5, -1):
		if s[x] == string[x - (n - 4)]:
			j += 1
		else:
			break
	if i + j >= 4:
		return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	print(func(s))


import re

def solve():
	input()
	s = input()
	l = []
	l.append('^2(.*?)020$')
	l.append('^20(.*?)20$')
	l.append('^202(.*?)0$')
	l.append('^(.*?)2020$')
	l.append('^2020(.*?)$')
	for i in l:
		if re.match(i, s):
			print('YES')
			return
	print('NO')
t = int(input())
for _ in range(t):
	solve()


import re
exp = '^(\\d*2020|2\\d*020|20\\d*20|202\\d*0|2020\\d*)$'
T = int(input())
for i in range(T):
	n = int(input())
	N = input()
	if re.match(exp, N):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	first_four = s[0:4]
	last_four = s[-1] + s[-2] + s[-3] + s[-4]
	last_four = last_four[::-1]
	if first_four == '2020' or last_four == '2020':
		print('YES')
	elif first_four[0] + last_four[1:] == '2020':
		print('YES')
	elif first_four[0:2] + last_four[2:] == '2020':
		print('YES')
	elif first_four[0:3] + last_four[3:] == '2020':
		print('YES')
	else:
		print('NO')