You have a string $s$ and a chip, which you can place onto any character of this string.

After placing the chip, you move it to the right several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is $i$, you move it to the position $i + 1$. Of course, moving the chip to the right is impossible if it is already in the last position.

After moving the chip to the right, you move it to the left several (maybe zero) times, i. e. you perform the following operation several times: if the current position of the chip is $i$, you move it to the position $i - 1$. Of course, moving the chip to the left is impossible if it is already in the first position.

When you place a chip or move it, you write down the character where the chip ends up after your action. For example, if $s$ is abcdef, you place the chip onto the $3$-rd character, move it to the right $2$ times and then move it to the left $3$ times, you write down the string cdedcb.

You are given two strings $s$ and $t$. Your task is to determine whether it's possible to perform the described operations with $s$ so that you write down the string $t$ as a result.


-----Input-----

The first line contains one integer $q$ ($1 \le q \le 500$) — the number of test cases.

Each test case consists of two lines. The first line contains the string $s$ ($1 \le |s| \le 500$), the second line contains the string $t$ ($1 \le |t| \le 2 \cdot |s| - 1$). Both strings consist of lowercase English characters.

It is guaranteed that the sum of $|s|$ over all test cases does not exceed $500$.


-----Output-----

For each test case, print "YES" if you can obtain the string $t$ by performing the process mentioned in the statement with the string $s$, or "NO" if you cannot.

You may print each letter in any case (YES, yes, Yes will all be recognized as positive answer, NO, no and nO will all be recognized as negative answer).


-----Examples-----

Input
6
abcdef
cdedcb
aaa
aaaaa
aab
baaa
ab
b
abcdef
abcdef
ba
baa
Output
YES
YES
NO
YES
YES
NO


-----Note-----

Consider the examples.

The first test case is described in the statement.

In the second test case, you can place the chip on the $1$-st position, move it twice to the right, and then move it twice to the left.

In the fourth test case, you can place the chip on the $2$-nd position, and then don't move it at all.

In the fifth test case, you can place the chip on the $1$-st position, move it $5$ times to the right, and then finish the process.

Difficulty: EASY
Tags: Dynamic programming

Complete search

Implementation

String algorithms
Skill types: Dynamic programming

Complete search

Starter code:

Solutions:
t = int(input())
for i in range(t):
	s = input()
	s2 = input()
	for j in range(len(s)):
		if s2 in s[:j] + s[j::-1]:
			print('YES')
			break
	else:
		print('NO')


import sys

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

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

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

def check(pointer, index, right_done=0):
	pointer += 1
	if pointer > len(t) - 1:
		return True
	if not right_done:
		if index + 1 < len(s) and t[pointer] == s[index + 1]:
			right = check(pointer, index + 1)
			if right:
				return True
	if index > 0 and t[pointer] == s[index - 1]:
		left = check(pointer, index - 1, right_done=1)
		if left:
			return True
	return False
for _ in '.' * read_int():
	s = input()
	t = input()
	pointer = 0
	ch = t[pointer]
	indexes = []
	for i in range(len(s)):
		if s[i] == ch:
			indexes.append(i)
	if len(indexes) == 0:
		write('NO')
		continue
	for index in indexes:
		if check(pointer, index):
			write('YES')
			break
	else:
		write('NO')


import sys
from collections import Counter
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(a, b):
	ind = [i for i in range(len(a)) if a[i] == b[0]]
	for i in ind:
		for j in range(i, len(a)):
			s = a[:j + 1] + a[:j][::-1]
			if b in s:
				print('YES')
				return
	print('NO')
for _ in range(int(input())):
	a = str(input())[:-1]
	b = str(input())[:-1]
	solve(a, b)


import sys
sys.setrecursionlimit(10 ** 5)

def p(s, t, idx, flg):
	if len(t) == 0:
		return True
	if flg:
		if idx + 1 < len(s) and s[idx + 1] == t[0]:
			if p(s, t[1:], idx + 1, True):
				return True
		if idx >= 1 and s[idx - 1] == t[0]:
			if p(s, t[1:], idx - 1, False):
				return True
	elif idx >= 1 and s[idx - 1] == t[0]:
		if p(s, t[1:], idx - 1, False):
			return True
	return False
Q = int(input())
for _ in range(Q):
	S = input()
	T = input()
	ts = T[0]
	for i in range(len(S)):
		if S[i] == ts:
			if p(S, T[1:], i, True):
				print('YES')
				break
	else:
		print('NO')


def main():
	S = input()
	N = len(S)
	T = input()
	M = len(T)
	for i in range(M):
		for j in range(i):
			if i * 2 - j >= M:
				continue
			if T[j] != T[i * 2 - j]:
				break
		else:
			s = T[:i * 2:-1] + T[:i + 1]
			for j in range(N - len(s) + 1):
				if S[j:j + len(s)] == s:
					break
			else:
				continue
			return print('YES')
	print('NO')
Q = int(input())
for _ in range(Q):
	main()


import sys
pl = 1
sys.setrecursionlimit(10 ** 5)
if pl:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('outpt.txt', 'w')

def li():
	return [int(xxx) for xxx in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

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

def ff():
	sys.stdout.flush()

def google(tc, *ans):
	print('Case #' + str(tc) + ':', *ans)
t = fi()
f = t
while t > 0:
	t -= 1
	a = si()
	b = si()
	n = len(a)
	m = len(b)
	flag = 0
	for i in range(n):
		for j in range(i, n):
			p = j - i + 1
			if p > m:
				break
			if m - p < p:
				r = a[i:j] + a[j - (m - p):j + 1][::-1]
			elif m - 2 * p + 1 <= i:
				r = a[i:j] + a[i:j + 1][::-1] + a[i - (m - 2 * p + 1):i][::-1]
			else:
				continue
			if r == b:
				flag = 1
				break
		if flag == 1:
			break
	print('YES' if flag else 'NO')


def answer(array, teststr):
	ans = 0
	for g in range(0, len(array)):
		if array[g].find(teststr) == -1:
			continue
		else:
			ans = 1
			break
	if ans == 0:
		print('NO')
	else:
		print('YES')
t = int(input())
for i in range(0, t):
	string = str(input())
	teststr = str(input())
	array = []
	array.append(string[0])
	for x in range(0, len(string)):
		ai = string[0:x + 1]
		bi = string[0:x]
		ci = bi[::-1]
		array.append(ai + ci)
	answer(array, teststr)


def solve():
	s = input()
	t = input()
	for fold_pos in range(0, len(t)):
		left = t[0:fold_pos + 1]
		right = t[fold_pos:len(t)][::-1]
		sym = True
		if len(left) > len(right):
			if not left.endswith(right):
				sym = False
		elif not right.endswith(left):
			sym = False
		if sym and left in s and (right in s):
			return True
	return False
n = int(input())
for _ in range(n):
	res = solve()
	if res:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(100000)
q = int(input())
s = ''
t = ''

def dfs(ind, isleft, tind):
	if s[ind] == t[tind]:
		tind += 1
	else:
		return False
	if tind == len(t):
		return True
	c = False
	if ind + 1 < len(s) and (not isleft):
		c = c or dfs(ind + 1, 0, tind)
	if ind - 1 >= 0:
		c = c or dfs(ind - 1, 1, tind)
	return c
for cas in range(q):
	s = input()
	t = input()
	c = False
	for x in range(len(s)):
		c = c or dfs(x, 0, 0)
	print('YES' if c else 'NO')


t = int(input())
for _ in range(t):
	s = input()
	t = input()
	ln = len(s)
	lt = len(t)
	if lt >= ln * 2:
		print('NO')
		continue
	for i in range(ln):
		new = s[:i] + s[:i + 1][::-1]
		if i * 2 + 1 < lt:
			continue
		if t in new:
			print('YES')
			break
	else:
		print('NO')


def solve(a, b):
	for i in range(len(a)):
		if solve_req(a, b, i):
			return 'YES'
	return 'NO'

def solve_req(a, b, i):
	if a[i] != b[0]:
		return False
	j = 0
	while i + j < len(a) and j < len(b) and (a[i + j] == b[j]):
		if solve_req1(a, b, i + j, j):
			return True
		j += 1
	return False

def solve_req1(a, b, i, j):
	k = 0
	while i - k >= 0 and j + k < len(b) and (a[i - k] == b[j + k]):
		if j + k + 1 == len(b):
			return True
		k += 1
	return False
q = int(input())
for _ in range(q):
	a = input()
	b = input()
	print(solve(a, b))


def sol():
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	for i in range(n):
		x = i
		p = 0
		op = ''
		while p < m and x < n:
			if s[x] == t[p]:
				p += 1
				op += s[x]
				if op == t:
					return 'YES'
				pp = p
				xx = x - 1
				op2 = op
				while pp < m and xx >= 0:
					if s[xx] == t[pp]:
						pp += 1
						op2 += s[xx]
						xx -= 1
					else:
						break
				if op2 == t:
					return 'YES'
				x += 1
			else:
				break
	return 'NO'

def main():
	for i in range(int(input())):
		print(sol())
main()


import math
import sys
inp = int(input())
for _ in range(inp):
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	y = False
	for i in range(n):
		for j in range(0, n - i):
			k = m - j - 1
			if i + j < k:
				continue
			l1 = i
			r = i + j
			l2 = r - k
			if s[l1:r + 1] + s[l2:r][::-1] == t:
				y = True
				break
	print('YES' if y else 'NO')


t = int(input())
for k in range(t):
	s = input()
	ss = input()
	flag = False
	for i in range(len(s)):
		if ss in s[:i] + s[i::-1]:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(s, ks) = (input(), input())
	a = []
	(n, m) = (len(s), len(ks))
	if ks in s:
		print('YES')
		continue
	for i in range(n):
		if s[i] == ks[0]:
			a.append([i, 0, True])
	c = 0
	for (i, j, k) in a:
		while True:
			if k:
				cij = True
				it = i
				jt = j
				if i + 1 < n and s[i + 1] == ks[j + 1]:
					i += 1
					j += 1
					cij = False
				if it - 1 > -1 and s[it - 1] == ks[jt + 1]:
					if cij:
						cij = False
						i -= 1
						j += 1
						k = False
					else:
						a.append([it - 1, jt + 1, False])
				if cij:
					break
			elif i - 1 > -1 and s[i - 1] == ks[j + 1]:
				j += 1
				i -= 1
			else:
				break
			if j >= m - 1:
				c = 1
				break
		if c:
			break
	if c:
		print('YES')
	else:
		print('NO')


tst = int(input())
for _ in range(tst):
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	ans = False
	for i in range(n):
		for j in range(i, n):
			k = m - (j - i + 1)
			if k < 0:
				continue
			pos = j - k
			if pos < 0:
				continue
			if s[i:j + 1] + s[pos:j][::-1] == t:
				ans = True
		if ans:
			break
	if ans:
		print('YES')
	else:
		print('NO')


import functools
import sys
sys.setrecursionlimit(4000)

def reverse_string(s, t):

	@functools.lru_cache()
	def dfs(i, j, right_flag):
		if j >= len(t):
			return True
		if i + 1 < len(s) and s[i + 1] == t[j] and right_flag:
			if dfs(i + 1, j + 1, right_flag):
				return True
		if i - 1 >= 0 and s[i - 1] == t[j]:
			if dfs(i - 1, j + 1, False):
				return True
		return False
	right_flag = True
	for i in range(len(s)):
		if s[i] == t[0] and dfs(i, 1, right_flag):
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	s = input()
	t = input()
	print(reverse_string(s, t))


import heapq
import sys
from math import *
import threading
from heapq import *
from itertools import count
from pprint import pprint
from collections import defaultdict
from heapq import heapify, heappop, heappush
mod = 10 ** 9 + 7
inf = 10 ** 15
decision = ['NO', 'YES']
yes = 'YES'
no = 'NO'
import os
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

	def npr(self, n, k):
		if k < 0 or n < k:
			return 0
		f = self.factorial
		return f.calc(n) * f.invFactorial(n - k) % self.MOD

def lower_bound(li, num):
	answer = len(li)
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = len(li)
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			start = middle + 1
		else:
			answer = middle
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [{1, i} for i in range(n + 1)]
	p = 2
	while p <= n:
		for i in range(p * 2, n + 1, p):
			prime[i].add(p)
		p += 1
	return prime

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def prod(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def sumk(a, b):
	print('called for', a, b)
	ans = a * (a + 1) // 2
	ans -= b * (b + 1) // 2
	return ans

def sumi(n):
	ans = 0
	if len(n) > 1:
		for x in n:
			ans += int(x)
		return ans
	else:
		return int(n)

def checkwin(x, a):
	if a[0][0] == a[1][1] == a[2][2] == x:
		return 1
	if a[0][2] == a[1][1] == a[2][0] == x:
		return 1
	if len(set(a[0])) == 1 and a[0][0] == x or (len(set(a[1])) == 1 and a[1][0] == x) or (len(set(a[2])) == 1 and a[2][0] == x):
		return 1
	if len(set(a[0][:])) == 1 and a[0][0] == x or (len(set(a[1][:])) == 1 and a[0][1] == x) or (len(set(a[2][:])) == 1 and a[0][0] == x):
		return 1
	return 0
inf = 10 ** 9 + 7

def main():
	karmanya = int(input())
	while karmanya != 0:
		karmanya -= 1
		s = input()
		t = input()
		(n, m, f) = (len(s), len(t), 0)
		for i in range(n):
			take = s[:i] + s[i::-1]
			if t in take:
				f = 1
				break
		print(decision[f])
main()


def solve():
	s = input()
	t = input()
	n = len(s)
	f = 0
	for i in range(n):
		curr = s[:i] + s[:i + 1][::-1]
		if t in curr:
			f = 1
			break
	print('YES' if f else 'NO')
t = int(input())
for _ in range(t):
	solve()


import os, sys, math
from io import BytesIO, IOBase
from collections import defaultdict, deque, OrderedDict
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

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

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

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

def Sn():
	return input().strip()
BUFSIZE = 8192

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def lcs():
	m = len(a)
	n = len(c)
	L = [[None] * (n + 1) for i in range(m + 1)]
	(res, pos) = (0, 0)
	for i in range(m + 1):
		for j in range(n + 1):
			if i == 0 or j == 0:
				L[i][j] = 0
			elif a[i - 1] == c[j - 1]:
				L[i][j] = L[i - 1][j - 1] + 1
				if L[i][j] > res:
					res = L[i][j]
					pos = j
			else:
				L[i][j] = 0
	ok = False
	for i in range(1, m + 1):
		for j in range(1, n + 1):
			po = j
			cnt = L[i][j]
			for k in range(i - 2, -1, -1):
				if po >= len(c):
					break
				if a[k] == c[po]:
					cnt += 1
				else:
					break
				po += 1
			if cnt == len(c):
				ok = True
				yes()
				return
	no()

def solve():
	global a, b, c
	a = Sn()
	b = Sn()
	c = b[::-1]
	lcs()
	pass

def main():
	T = I()
	for i in range(T):
		solve()
M = 998244353
P = 1000000007

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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	s = input()
	m = input()
	ans = False
	for i in range(len(s)):
		if m in s[:i] + s[i::-1]:
			ans = True
			break
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	s = input()
	t = input()
	for x in range(len(s)):
		if t in s[:x] + s[x::-1]:
			print('YES')
			break
	else:
		print('NO')


def init_stage(s, t):
	for i in range(len(s)):
		if s[i] == t[0]:
			if first_stage(s, t, i, 1):
				return True
	return False

def first_stage(s, t, i, comp):
	if comp == len(t):
		return True
	if i + 1 < len(s):
		if s[i + 1] == t[comp]:
			if first_stage(s, t, i + 1, comp + 1):
				return True
	if i > 0:
		if s[i - 1] == t[comp]:
			if second_stage(s, t, i - 1, comp + 1):
				return True
	return False

def second_stage(s, t, i, comp):
	if comp == len(t):
		return True
	if i > 0:
		if s[i - 1] == t[comp]:
			if second_stage(s, t, i - 1, comp + 1):
				return True
	return False
for _ in range(int(input())):
	s = input()
	t = input()
	if init_stage(s, t):
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	s = input()
	t = input()
	found = 0
	for i in range(len(s)):
		new = s[:i] + s[i::-1]
		if new.find(t) != -1:
			print('YES')
			found = 1
			break
	if found == 0:
		print('NO')


t = int(input())
for p in range(t):
	s = input()
	t = input()
	if t in s:
		print('YES')
	elif t[::-1] in s:
		print('YES')
	else:
		flag = 0
		for i in range(1, len(s) + 1):
			tmp = s[:i] + s[:i - 1][::-1]
			if t in tmp:
				flag = 1
				print('YES')
				break
		if flag == 0:
			print('NO')


def reverse_string(s, t):
	if t in s or t[::-1] in s:
		return True
	(n, m) = (len(s), len(t))
	for i in range(1, m - 1):
		(left, right) = (i - 1, i + 1)
		is_pali = True
		while left >= 0 and right <= m - 1:
			if t[left] == t[right]:
				left -= 1
				right += 1
			else:
				is_pali = False
				break
		if is_pali:
			if left == -1:
				if right != m:
					if t[i:][::-1] in s:
						return True
				elif t[:i + 1] in s:
					return True
			elif t[:i + 1] in s:
				return True
	return False
T = int(input())
for t in range(T):
	s = input()
	t = input()
	if reverse_string(s, t):
		print('YES')
	else:
		print('NO')


def left(a, i, t, x, ltt):
	if x == ltt:
		return True
	while x != ltt + 1:
		if x == ltt:
			return True
		if i - 1 >= 0 and a[i - 1] == t[x]:
			x += 1
			i -= 1
		else:
			return False

def right(a, i, t, x, ltt):
	F1 = False
	F2 = False
	if ltt == x:
		return True
	if i - 1 >= 0 and a[i - 1] == t[x]:
		F1 = left(a, i, t, x, ltt)
	if i + 1 < len(a) and a[i + 1] == t[x]:
		F2 = right(a, i + 1, t, x + 1, ltt)
	if F1 == True or F2 == True:
		return True
	else:
		return False
t = int(input())
for x in range(t):
	a = input()
	t = input()
	ltt = len(t)
	S = False
	for m in range(len(a)):
		if t[0] == a[m]:
			S = right(a, m, t, 1, ltt)
			if S == True:
				break
	if S == True:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 6)
from sys import stdin, stdout

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

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

def num2in():
	(a, b) = map(int, stdin.readline().split())
	return (a, b)

def num3in():
	(a, b, c) = map(int, stdin.readline().split())
	return (a, b, c)

def num4in():
	(a, b, c, d) = map(int, stdin.readline().split())
	return (a, b, c, d)

def num5in():
	(a, b, c, d, e) = map(int, stdin.readline().split())
	return (a, b, c, d, e)

def recur(s1, s2, i, j, dir):
	if i >= len(s1) or i < 0:
		return False
	if s1[i] != s2[j]:
		return False
	if j == len(s2) - 1:
		return True
	if dir == 0:
		return recur(s1, s2, i - 1, j + 1, 0)
	else:
		return recur(s1, s2, i + 1, j + 1, 1) or recur(s1, s2, i - 1, j + 1, 0)
t = num1in()
for test in range(t):
	s1 = input()
	s2 = input()
	flag = 1
	for i in range(len(s1)):
		if recur(s1, s2, i, 0, 1):
			print('YES')
			flag = 0
			break
	if flag == 1:
		print('NO')


def left(s, t, i, x):
	while x < len(t) and i >= 0:
		if t[x] == s[i]:
			x += 1
			i = i - 1
		else:
			break
	if x == len(t):
		return 1
	return 0

def right(s, t, i, x):
	if x == len(t):
		return 1
	if x + 1 == len(t):
		if i + 1 < len(s) and s[i + 1] == t[x]:
			return 1
		elif i - 1 >= 0 and s[i - 1] == t[x]:
			return 1
		else:
			return 0
	r1 = 0
	r2 = 0
	if i - 1 >= 0 and s[i - 1] == t[x]:
		r1 = left(s, t, i - 1, x)
	if r1:
		return 1
	if i + 1 < len(s) and s[i + 1] == t[x]:
		r2 = right(s, t, i + 1, x + 1)
	return r1 or r2
for _ in range(int(input())):
	s = input()
	t = input()
	f = 0
	l = len(t)
	for i in range(len(s)):
		if s[i] == t[0]:
			f = right(s, t, i, 1)
			if f == 1:
				break
	if f:
		print('YES')
	else:
		print('NO')


def solve():
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	ans = False
	for i in range(n):
		for j in range(0, n - i):
			k = m - 1 - j
			if i + j < k:
				continue
			l1 = i
			r = i + j
			l2 = r - k
			if s[l1:r + 1] + s[l2:r][::-1] == t:
				ans = True
	print('YES' if ans else 'NO')

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


t = int(input())
for _ in range(t):
	(s, t) = (input().strip(), input().strip())
	c = any((t in s[:x] + s[x::-1] for x in range(len(s))))
	print('YES' if c else 'NO')


def solve():
	s1 = input()
	s2 = input()
	strings = []
	for i in range(len(s1)):
		for j in range(i + 1, len(s1) + 1):
			cur = s1[i:j]
			cur += s1[:j - 1][::-1]
			strings.append(cur)
	for s in strings:
		for i in range(len(s2)):
			if i >= len(s):
				break
			if s[i] != s2[i]:
				break
			if s[i] == s2[i] and i + 1 == len(s2):
				print('YES')
				return
	print('NO')

def main():
	for case in range(int(input())):
		solve()
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
import sys, io, os
INP = sys.stdin.readline
inp = lambda : [*map(int, INP().encode().split())]
sinp = lambda : [*map(str, INP().split())]
out = sys.stdout.write

def main():
	for _ in range(inp()[0]):
		l = list(input())
		a = list(input())
		j = 0
		m = 0
		check = 0
		while m < len(l) and j < len(a):
			if l[m] == a[j]:
				i = m
				while m < len(l) and j < len(a):
					if l[m] == a[j]:
						k = m - 1
						r = j + 1
						while k > -1 and r < len(a):
							if l[k] == a[r]:
								k -= 1
								r += 1
							else:
								break
						if r == len(a):
							check = 1
							break
						m += 1
						j += 1
					else:
						break
				if j == len(a) or check:
					check = 1
					break
				m = i
				j = 0
			if check:
				break
			m += 1
		if check or j == len(a):
			print('YES')
		else:
			print('NO')

def SumOfExpOfFactors(a):
	fac = 0
	lis = SortedList()
	if not a & 1:
		lis.add(2)
	while not a & 1:
		a >>= 1
		fac += 1
	for i in range(3, int(a ** 0.5) + 1, 2):
		if not a % i:
			lis.add(i)
		while not a % i:
			a //= i
			fac += 1
	if a != 1:
		lis.add(a)
		fac += 1
	return (fac, lis)
div = [0] * 1000001

def NumOfDivisors(n):
	for i in range(1, n + 1):
		for j in range(i, n + 1, i):
			div[j] += 1

def primes1(n):
	sieve = [True] * (n // 2)
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i // 2]:
			sieve[i * i // 2::i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [2 * i + 1 for i in range(1, n // 2) if sieve[i]]

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

class Graph:

	def __init__(self):
		self.Graph = defaultdict(list)

	def addEdge(self, u, v):
		self.Graph[u].append(v)
		self.Graph[v].append(u)

	def DFSUtil(self, v, visited):
		visited.add(v)
		for neighbour in self.Graph[v]:
			if neighbour not in visited:
				self.DFSUtil(neighbour, visited)

	def DFS(self, v):
		visited = set()
		self.DFSUtil(v, visited)

	def BFS(self, s):
		visited = set()
		queue = []
		queue.append(s)
		visited.add(s)
		while queue:
			s = queue.pop(0)
			for i in self.Graph[s]:
				if i not in visited:
					queue.append(i)
					visited.add(i)

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))
main()


import traceback
import os
import sys
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 = IOWrapper(sys.stdin)
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import defaultdict as dfd, Counter
from functools import lru_cache
from itertools import accumulate

def geti():
	return int(input())

def gets():
	return input()

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

def getsl():
	return input().split()

def getinps(s):
	inps = s.split()
	m = {'i': geti, 's': gets, 'il': getil, 'sl': getsl}
	if len(inps) == 1:
		return m[s]()
	return [m[k]() for k in inps]

def get2d(nrows, ncols, n=0):
	return [[n] * ncols for r in range(nrows)]

def get_acc(a):
	return list(accumulate(a))

def get_ncr(n, r, mod=10 ** 9 + 7):
	num = den = 1
	r = min(r, n - r)
	for i in range(r):
		num = num * (n - i) % mod
		den = den * (i + 1) % mod
	return num * pow(den, mod - 2, mod) % mod

def get_nc2(n):
	return n * (n - 1) // 2

def get_npr(n, r):
	if n < r:
		return 0
	return math.factorial(n) // math.factorial(r)

def put(a):
	return ' '.join(map(str, a))
inf = float('inf')
mod = 10 ** 9 + 7

def main():
	(a, b) = getinps('s s')
	(n, m) = (len(a), len(b))

	def check(i, j, t):
		if j == m:
			return True
		if not (0 <= i < n and 0 <= j < m):
			return False
		if a[i] == b[j]:
			return t == 0 and check(i + 1, j + 1, 0) or check(i - 1, j + 1, 1)
		else:
			return False
	return any((check(i, 0, 0) for i in range(n)))
try:
	Test = geti()
	answers = []
	for _ in range(Test):
		ans = main()
		ans = 'YES' if ans else 'NO'
		ans = str(ans)
		answers.append(ans)
	print('\n'.join(answers))
except Exception as e:
	print(e)
	traceback.print_exc()


from sys import stdin, stdout
input = stdin.readline
mp = lambda : map(int, input().split())
it = lambda : int(input())
ls = lambda : list(input().strip())
mt = lambda r: [ls() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)

def fibo_n(n):
	return ((1 + sqrt(5)) / 2) ** n / sqrt(5)
for _ in range(it()):
	a = input().strip()
	b = input().strip()
	ans = 'NO'
	for i in range(len(a)):
		for mov in range(len(b) + 1):
			s = a[i:i + mov]
			rem = len(b) - mov
			cur = i + mov - 2
			for j in range(rem):
				if cur >= 0 and cur < len(a):
					s += a[cur]
					cur -= 1
			if s == b:
				ans = 'YES'
				break
		if ans == 'YES':
			break
	print(ans)


for q in range(int(input())):
	str_1 = input()
	str_2 = input()
	len_1 = len(str_1)
	len_2 = len(str_2)
	ans = False
	for i in range(len_1):
		for j in range(0, len_1 - i):
			k = len_2 - 1 - j
			if i + j < k:
				continue
			l1 = i
			r = i + j
			l2 = r - k
			if str_1[l1:r + 1] + str_1[l2:r][::-1] == str_2:
				ans = True
	print('yes' if ans else 'no')


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7
for _ in range(int(input())):
	a = [i for i in input()]
	b = [i for i in input()]
	n = len(b)
	bol = False
	for i in range(len(b) + 1):
		for j in range(len(a)):
			ck = []
			if j - i >= 0 and j - (n - 1 - i) >= 0:
				for k in range(j - i, j):
					ck.append(a[k])
				ck.append(a[j])
				for k in range(j - 1, j - (n - 1 - i) - 1, -1):
					ck.append(a[k])
			if ck == b:
				bol = True
				break
		if bol:
			break
	if bol:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	isTrue = False
	for i in range(1, len(s)):
		tmp = s[:i] + s[i] + s[:i][::-1]
		if len(tmp) >= len(t):
			if t in tmp:
				isTrue = True
				break
	if isTrue:
		print('YES')
	elif t in s[::-1]:
		print('YES')
	else:
		print('NO')


def rd():
	return int(input())
t = rd()
for i in range(t):
	a = input()
	b = input()
	n = len(a)
	m = len(b)
	pok = 0
	for i in range(n):
		_r = 0
		cnt = 0
		while i + _r < n:
			if pok == 1:
				break
			if a[i + _r] != b[cnt]:
				break
			else:
				cnt = cnt + 1
			_l = 1
			if cnt == m:
				print('YES')
				pok = 1
			necnt = cnt
			while i + _r - _l >= 0:
				if pok == 1:
					break
				if a[i + _r - _l] != b[necnt]:
					break
				else:
					necnt = necnt + 1
				if necnt == m:
					print('YES')
					pok = 1
				_l = _l + 1
			_r = _r + 1
	if pok == 0:
		print('NO')


t = int(input())

def find_locs(a, b):
	nats = []
	for i in range(len(a) - len(b) + 1):
		now = a[i:i + len(b)]
		if now == b:
			nats += [i]
	return nats
for i in range(t):
	s = input()
	m = input()
	nat = 'YES'
	done = False
	if m[::-1] in s:
		done = True
	i = 0
	while not done:
		i += 1
		locs = find_locs(s, m[:i])
		for c in locs:
			if s[c + i - (len(m) - i) - 1:c + i - 1] == m[i:][::-1]:
				done = True
		if i == len(m) + 1:
			done = True
			nat = 'No'
	print(nat)


I = input
exec(int(I()) * "s=I();t=I();print('NYOE S'[any(t in s[:i]+s[i::-1]for i in range(len(s)))::2]);")


t = int(input())
for i in range(0, t):
	s = str(input())
	t = str(input())
	arr = []
	arr.append(s[0])
	for x in range(0, len(s)):
		a = s[0:x + 1]
		b = s[0:x]
		c = b[::-1]
		arr.append(a + c)
	c = 0
	for j in range(0, len(arr)):
		if arr[j].find(t) == -1:
			continue
		else:
			c = 1
			break
	if c == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	s1 = str(input())
	s2 = str(input())
	arr = []
	for j in range(len(s1)):
		if s1[j] == s2[0]:
			arr.append(j)
	result = False
	for j in range(len(arr)):
		for k in range(len(s1) - arr[j]):
			a = len(s2) - k
			if len(s2) - 2 * (1 + k) + 1 <= arr[j]:
				sdash = s1[arr[j]:arr[j] + k + 1] + s1[arr[j] + k - (len(s2) - k - 1):arr[j] + k][::-1]
				if sdash == s2:
					result = True
					break
	if result == True:
		print('Yes')
	else:
		print('No')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	ans = False
	for i in range(n):
		for j in range(0, n - i):
			k = m - 1 - j
			if i + j < k:
				continue
			l1 = i
			r = i + j
			l2 = r - k
			if s[l1:r + 1] + s[l2:r][::-1] == t:
				ans = True
	print('YES' if ans else 'NO')


tt = int(input())
for _ in range(tt):
	s = input()
	t = input()
	n = len(t)
	m = n
	for i in range(n // 2, n - 1):
		flag = True
		for j in range(1, n - i):
			if t[i - j] != t[i + j]:
				flag = False
				break
		if flag:
			m = i
			break
	ans = t[:m + 1] in s
	if not ans:
		t = t[::-1]
		m = n
		for i in range(n // 2, n - 1):
			flag = True
			for j in range(1, n - i):
				if t[i - j] != t[i + j]:
					flag = False
					break
			if flag:
				m = i
				break
		ans = t[:m + 1] in s
	print('YES' if ans else 'NO')


def solve(s, t):
	n1 = len(s)
	n2 = len(t)
	for i in range(n1):
		if t[0] == s[i]:
			j = 0
			k = i
			while j < n2 and k < n1 and (s[k] == t[j]):
				j += 1
				kk = k - 1
				jj = j
				k += 1
				while kk >= 0 and jj < n2 and (s[kk] == t[jj]):
					jj += 1
					kk -= 1
				if jj == n2:
					return 'YES'
	return 'NO'
for _ in range(int(input())):
	s = input()
	t = input()
	print(solve(s, t))


def solve():
	for i in range(0, l1):
		for j in range(i, l1):
			if s1[i:j] + s1[j:j - (l2 - j + i):-1] == s2 or s1[i:j] + s1[j::-1] == s2:
				print('YES')
				return
	print('NO')
for _ in range(int(input())):
	s1 = input()
	l1 = len(s1)
	s2 = input()
	l2 = len(s2)
	solve()


q = int(input())
while q:
	q -= 1
	s = input()
	t = input()
	start = []
	for i in range(len(s)):
		if s[i] == t[0]:
			start.append(i)
	end = []
	while start:
		i = start.pop()
		end.append([i, 0])
		i += 1
		for j in range(1, len(t)):
			if i >= len(s):
				end.append([i - 1, j - 1])
				break
			if s[i] == t[j]:
				end.append([i, j])
				i += 1
			else:
				end.append([i - 1, j - 1])
				break
		else:
			end.append([i - 1, len(s) - 1])
	while end:
		(i, j) = end.pop()
		if len(t) - j - 1 <= i and t[j + 1:] == s[i - (len(t) - j - 1):i][-1::-1]:
			print('yes')
			break
	else:
		print('no')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	s = input()[:-1]
	w = input()[:-1]
	n = len(w)
	for i in range(1, n):
		a = w[:i]
		b = w[i:][::-1] + a[-1]
		x = len(a)
		y = len(b)
		if x >= y:
			if b != a[x - y:]:
				continue
			else:
				c = a
		elif a != b[y - x:]:
			continue
		else:
			c = b
		if c in s:
			print('YES')
			break
	else:
		if w in s or w in s[::-1]:
			print('YES')
		else:
			print('NO')


t = int(input())
for i in range(t):
	s = str(input())
	l = str(input())
	flag = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s) + 1):
			s = list(s)
			x = ''
			x = ''.join(s[i:j]) + ''.join(list(reversed(s[j - 1 - (len(l) - j + i):j - 1])))
			if x == l:
				print('YES')
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')


t = int(input())
for q in range(t):
	ch1 = input()
	ch2 = input()
	n = len(ch1)
	l = [''] * n
	s1 = ''
	s2 = ''
	test = False
	for i in range(n):
		x = s1 + ch1[i] + s2
		l[i] = x
		s1 = s1 + ch1[i]
		s2 = ch1[i] + s2
	for i in range(n):
		if l[i].count(ch2):
			test = True
			break
	if test:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(s, t) = (input(), input())
	f = 0
	for i in range(len(s)):
		temp = s[:i] + s[i::-1]
		if t in temp:
			f = 1
			break
	if f:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	t = input()
	flag = 0
	for j in range(len(s)):
		if t in s[:j] + s[j::-1]:
			flag = 1
	if flag:
		print('YES')
	else:
		print('NO')


def solve():
	N = len(S)
	for i in range(N):
		for j in range(i, N):
			end = j - (len(T) - 1 - (j - i))
			if end < 0:
				continue
			candidate = S[i:j + 1] + S[end:j][::-1]
			if candidate == T:
				return 'yes'
	return 'no'
test_cases = int(input())
for test_case in range(test_cases):
	S = input()
	T = input()
	print(solve())


def step(line, target, current_position, current_index, only_left):
	if current_index == len(target):
		return True
	if not only_left and current_position < len(line) - 1:
		if line[current_position + 1] == target[current_index]:
			if step(line, target, current_position + 1, current_index + 1, False):
				return True
	if current_position > 0:
		if line[current_position - 1] == target[current_index]:
			if step(line, target, current_position - 1, current_index + 1, True):
				return True
	return False
n = int(input())
for _ in range(n):
	line = input().strip()
	target = input().strip()
	found = False
	for i in range(len(line)):
		if target[0] == line[i]:
			if step(line, target, i, 1, False):
				found = True
				break
	print('YES' if found else 'NO')


def handle(a, b):
	for i in range(0, len(a)):
		for j in range(0, len(b)):
			cur = i
			loop = 0
			if a[cur] != b[loop]:
				break
			loop += 1
			for k in range(0, min(j, len(a) - i - 1)):
				cur += 1
				if a[cur] != b[loop]:
					break
				loop += 1
			for k in range(0, min(len(b) - j - 1, cur)):
				cur -= 1
				if a[cur] != b[loop]:
					break
				loop += 1
			if loop == len(b):
				return 1
	return 0
n = int(input())
for loop in range(0, n):
	s = input()
	t = input()
	if handle(s, t):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	n = len(s)
	ans = 'NO'
	for i in range(n):
		for j in range(i, n):
			curr = s[i:j + 1]
			if curr == t:
				ans = 'YES'
				break
			for k in range(j - 1, -1, -1):
				curr = curr + s[k]
				if curr == t:
					ans = 'YES'
					break
			if ans == 'YES':
				break
	print(ans)


def solve():
	s = input()
	t = input()
	return any((t in s[:i] + s[i::-1] for i in range(len(s))))
t = int(input())
for __ in range(t):
	print('YES' if solve() else 'NO')


def solve(s, t):
	for (i, letter) in enumerate(s):
		pointer = i
		if letter == t[0]:
			for j in range(min(len(s) - i, len(t))):
				right_moves = s[pointer + 1:pointer + j + 1]
				left_start = max(0, pointer + j - (len(t) - j - 1))
				left_moves = s[left_start:pointer + j][::-1]
				if t == s[pointer] + right_moves + left_moves:
					return 'YES'
	return 'NO'
import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input().decode().strip())
for t in range(T):
	s = input().decode().strip()
	t = input().decode().strip()
	res = solve(s, t)
	print(res)


def sol():
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	res = 0
	for i in range(n):
		for j in range(0, n - i):
			k = m - j - 1
			if i + j < k:
				continue
			l1 = i
			r1 = i + j
			l2 = r1 - k
			if s[l1:r1 + 1] + s[l2:r1][::-1] == t:
				res = 1
	if res:
		print('YES')
	else:
		print('NO')
try:
	for _ in range(int(input())):
		sol()
except:
	pass


testcases = []
n = int(input())
for _ in range(n):
	s = input()
	t = input()
	testcases.append((s, t))

def find_all(ch, s):
	indexes = []
	for (i, item) in enumerate(s):
		if item == ch:
			indexes.append(i)
	return indexes

def check(s, t):
	if t[0] not in s:
		return 'NO'
	indexes = find_all(t[0], s)
	for index in indexes:
		if t in s[:index + 1][::-1]:
			return 'YES'
		elif t in s[index:]:
			return 'YES'
		elif index == len(s) - 1:
			return 'NO'
		else:
			for i in range(len(s[index:]) - 1):
				try:
					if t in s[index:index + 2 + i] + s[:index + 1 + i][::-1]:
						return 'YES'
				except IndexError:
					continue
	return 'NO'
for test in testcases:
	print(check(*test))


from functools import lru_cache
import sys
sys.setrecursionlimit(5000)

def solve(s, t):

	@lru_cache(maxsize=None)
	def dfs(i, j, turn=True):
		if j == len(t):
			return True
		if i + 1 < len(s) and s[i + 1] == t[j] and turn:
			if dfs(i + 1, j + 1, turn):
				return True
		if i - 1 >= 0 and s[i - 1] == t[j]:
			if dfs(i - 1, j + 1, False):
				return True
		return False
	for (i, c) in enumerate(s):
		if c != t[0]:
			continue
		if dfs(i, 1, 1):
			return 'YES'
	return 'NO'
ans = []
for _ in range(int(input())):
	ans.append(solve(input(), input()))
print(*ans, sep='\n')


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


import sys
from math import cos, pi, ceil, pi, tan, floor, gcd, sqrt, log2, factorial, log10
from collections import Counter
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase
from statistics import mean, median, mode
alpha = ascii_lowercase
beta = ascii_uppercase

def nextPowerOf2(n):
	p = 1
	if n and (not n & n - 1):
		return n
	while p < n:
		p <<= 1
	return p

def get_Divisors(n):
	arr = []
	i = 1
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				arr.append(i)
			else:
				arr.append(i)
				arr.append(n // i)
		i = i + 1
	return arr

def isprime(n):
	if n == 1:
		return 0
	i = 2
	while i * i <= n:
		if n % i == 0:
			return 0
		i += 1
	return 1

def Sieve(n):
	prime = [True for i in range(n + 1)]
	prime[0] = False
	prime[1] = False
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def create_matrix(n, m):
	mat = [[] for i in range(n)]
	for i in range(n):
		for j in range(m):
			mat[i].append(0)
	return mat

def main():
	for ttt in range(int(input())):
		s = input().strip()
		t = input().strip()
		n = len(s)
		m = len(t)
		ans = 0
		for i in range(n):
			ss = ''
			for j in range(i, n):
				ss += s[j]
				sss = ss
				if sss == t:
					ans = 1
					break
				for k in range(j - 1, -1, -1):
					if k >= 0:
						sss += s[k]
					if sss == t:
						ans = 1
						break
				if ans == 1:
					break
			if ans == 1:
				break
		if ans == 1:
			print('yes')
		else:
			print('no')
main()


t = int(input())
for _ in range(t):
	s = input()
	t = input()
	ans = 'NO'
	for i in range(len(s)):
		if ans == 'YES':
			break
		for j in range(len(s) - i):
			k = len(t) - j - 1
			if i + j < k:
				continue
			if ans == 'YES':
				break
			l1 = i
			r = i + j
			l2 = r - k
			if s[l1:r + 1] + s[l2:r][::-1] == t:
				ans = 'YES'
	print(ans)


q = int(input())
while q > 0:
	q -= 1
	s = input()
	t = input()
	n = len(s)
	ar = set()
	flag = False
	for i in range(2, n + 1):
		z = s[0:i]
		z = z + z[-2::-1]
		ar.add(z)
	ar.add(s[0])
	for k in ar:
		if t in k:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


import collections
from collections import defaultdict
import math
from math import gcd
from collections import Counter

def fun(a, ind):
	(i, j) = (ind - 1, ind + 1)
	while i >= 0 and j < n and (a[i] == a[j]):
		i -= 1
		j += 1
	if i < 0 or j >= n:
		return True
for _ in range(int(input())):
	s = input()
	t = input()
	n = len(t)
	pivot = [0, n - 1]
	for i in range(1, n - 1):
		if fun(t, i):
			pivot.append(i)
	ans = False
	for ind in pivot:
		right = t[:ind]
		left = t[ind + 1:]
		temp = right
		if len(right) < len(left):
			temp = left[::-1]
		ans = ans or temp + t[ind] in s
		if ans:
			break
	if ans:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = input()
	b = input()
	n = len(a)
	m = len(b)
	ans = 0
	for i in range(n):
		if ans == 1:
			break
		for j in range(i, n):
			ind = 0
			res = 1
			for k in range(i, j + 1):
				if a[k] != b[ind]:
					res = 0
					break
				ind += 1
			if j - i + 1 + j < m:
				res = 0
			else:
				for k in range(j - 1, -1, -1):
					if ind == m:
						break
					if a[k] != b[ind]:
						res = 0
						break
					ind += 1
			if res == 1:
				ans = 1
				break
	if ans == 1:
		print('YES')
	else:
		print('NO')


import sys
from collections import defaultdict
sys.setrecursionlimit(1000000)

def solve(cps, cpt, l, r):
	if cpt >= n:
		return True
	ans = False
	if r and cps + 1 < m and (cps + 1 >= 0) and (s[cps + 1] == t[cpt]):
		ans = ans | solve(cps + 1, cpt + 1, True, True)
	if l and cps - 1 >= 0 and (cps - 1 < m) and (s[cps - 1] == t[cpt]):
		ans = ans | solve(cps - 1, cpt + 1, True, False)
	return ans
for i in range(int(input())):
	s = input()
	t = input()
	n = len(t)
	m = len(s)
	ans = False
	for j in range(m):
		if s[j] == t[0]:
			ans = solve(j, 1, True, True)
		if ans:
			print('YES')
			break
	if not ans:
		print('NO')


import os
import sys
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for t in range(int(input())):
	s = input()
	t = input()
	ans = 'NO'
	if t in s:
		print('YES')
		continue
	for i in range(len(s)):
		if s[i] == t[0]:
			for j in range(1, len(t) + 1):
				if i + j > len(s):
					continue
				if i + j - 1 - len(t) + j - 1 < -1:
					continue
				if i + j - 1 - (len(t) - j) - 1 == -1:
					x = s[i + j - 2::-1]
				else:
					x = s[i + j - 1 - 1:i + j - 1 - (len(t) - j) - 1:-1]
				if s[i:i + j] == t[:j] and x == t[j:]:
					ans = 'YES'
					break
		if ans == 'YES':
			break
	print(ans)


def u():
	return map(int, input().split())
for _ in range(int(input())):
	s = input()
	t = input()
	tlen = len(t)
	slen = len(s)
	starts = list()
	for i in range(slen):
		if s[i] == t[0]:
			starts.append(i)
	b = False
	for x in range(tlen):
		if b:
			break
		tmp = []
		for st in starts:
			if b:
				break
			if st + x < slen:
				rstr = s[st:st + x + 1]
				have = x + 1
				rem = tlen - have
				if st + x - rem < 0:
					continue
				for i in range(rem):
					tmp.append(s[st + x - i - 1])
				whole = rstr + ''.join(tmp)
				if whole == t:
					print('Yes')
					b = True
			tmp = []
	tmp = []
	if not b:
		print('No')


n = int(input())
for i in range(n):
	main_str = input()
	expected_str = input()
	seq_found = False
	for j in range(len(main_str)):
		if expected_str in main_str[:j] + main_str[j::-1]:
			print('YES')
			seq_found = True
			break
	if not seq_found:
		print('NO')


def main():
	nums1 = input()
	nums2 = input()
	(len1, len2) = (len(nums1), len(nums2))

	def dp(i, j, t):
		if j == len2:
			return True
		if not (0 <= i < len1 and 0 <= j < len2):
			return False
		if nums1[i] == nums2[j]:
			return t == 0 and dp(i + 1, j + 1, 0) or dp(i - 1, j + 1, 1)
		else:
			return False
	ans = any((dp(i, 0, 0) for i in range(len1)))
	ans = 'YES' if ans else 'NO'
	print(ans)
t = int(input())
for _ in range(t):
	ans = main()


def solve(s, t):
	for i in range(1, len(s) + 1):
		x = s[:i] + s[:i - 1][::-1]
		if t in x:
			return 1
	return 0
import sys
input = lambda : sys.stdin.readline().rstrip()
ans = ['NO', 'YES']
tt = int(input())
for i in range(tt):
	s = input()
	t = input()
	print(ans[solve(s, t)])


def func(s, t, k, place1, place2, len1, len2):
	if place2 == len2:
		return True
	if s[place1] != t[place2]:
		return False
	if place2 == len2 - 1:
		return True
	if place1 == len1 - 1:
		return func(s, t, 1, len1 - 2, place2 + 1, len1, len2)
	if place1 == 0:
		if k == 0:
			return func(s, t, 0, 1, place2 + 1, len1, len2)
		if k == 1:
			return False
	if k == 0:
		return func(s, t, 0, place1 + 1, place2 + 1, len1, len2) + func(s, t, 1, place1 - 1, place2 + 1, len1, len2)
	return func(s, t, 1, place1 - 1, place2 + 1, len1, len2)
t = int(input())
for w in range(t):
	s = input()
	t = input()
	len1 = len(s)
	len2 = len(t)
	ans = 0
	for i in range(len1):
		if func(s, t, 0, i, 0, len1, len2):
			print('yes')
			ans = 1
			break
	if ans == 0:
		print('no')


for z in range(int(input())):
	a = input()
	b = input()
	ans = 'NO'
	for i in range(len(a)):
		if b in a[:i] + a[i::-1]:
			ans = 'YES'
			break
	print(ans)


import typing
import sys
sys.setrecursionlimit(1 << 20)

def solve(s: str, t: str) -> typing.NoReturn:

	def dfs(i: int, j: int, d: int) -> bool:
		if j == len(t):
			return True
		if i < 0 or len(s) <= i:
			return False
		if s[i] != t[j]:
			return False
		ok = dfs(i - 1, j + 1, 0)
		if d == 0:
			return ok
		ok |= dfs(i + 1, j + 1, 1)
		return ok
	for i in range(len(s)):
		ok = dfs(i, 0, 1)
		if ok:
			print('YES')
			break
	else:
		print('NO')

def main() -> typing.NoReturn:
	q = int(input())
	for _ in range(q):
		s = input()
		t = input()
		solve(s, t)
main()


t = int(input())
for _ in range(t):
	(s, t) = (input().strip(), input().strip())
	b = any((t in s[:i] + s[i::-1] for i in range(len(s))))
	print('YES' if b else 'NO')


def chk(l2, l1, a1, a2, i):
	ag = l2[-1]
	lg = list(l1)
	lg.reverse()
	lg = ''.join(lg)
	for j in range(len(a1)):
		if a1[j] == ag and j + 1 >= len(l2) and (j + 1 >= len(l1)):
			if a1[j - len(l2) + 1:j + 1] == l2 and a1[j - len(l1) + 1:j + 1] == lg:
				return 1
	return 0
for _ in range(int(input())):
	a1 = input()
	a2 = list(a1)
	a2.reverse()
	a2 = ''.join(a2)
	b = input()
	f = 0
	for i in range(len(b)):
		l1 = b[i:]
		l2 = b[:i + 1]
		if l1 in a2 and l2 in a1:
			if chk(l2, l1, a1, a2, i):
				f = 1
				break
	if f == 1:
		print('YES')
	else:
		print('NO')


def func():
	s = input()
	t = input()
	for i in range(len(t) + 1):
		f = t[:i]
		e = t[i:][::-1]
		if len(f):
			e += f[-1]
		if len(e) == 0 and f in s:
			print('YES')
			return True
		if len(f) == 0 and e in s:
			print('YES')
			return True
		if len(e) > len(f) and e.endswith(f) and (e in s):
			print('YES')
			return True
		if len(f) > len(e) and f.endswith(e) and (f in s):
			print('YES')
			return True
		if len(f) == len(e) and f == e and (f in s):
			print('YES')
			return True
	print('NO')
	return True
for i in range(int(input())):
	func()


def sub_string(s, t):
	if t in s:
		return True
	if t[::-1] in s:
		return True
	return False

def poly(st):
	if st == st[::-1]:
		return True
	return False

def big_pol(s, t):
	if poly(t) and len(t) == 2 * len(s) - 1:
		if t[:len(t) // 2 + 1] in s:
			return True
	for i in range(1, len(t)):
		if poly(t[:-i]) and len(t[:-i]) % 2 != 0:
			if t[-i:][::-1] + t[:-i][:len(t[:-i]) // 2 + 1] in s:
				return True
	return False

def little_pol(s, t):
	for i in range(1, len(t)):
		if poly(t[i:]) and len(t[i:]) % 2 != 0:
			if t[:i] + t[i:][:len(t[:-i]) // 2 + 1] in s:
				return True
	return False

def poly_mid(s, t):
	if poly(t) and len(t) % 2 != 0:
		if t[:len(t) // 2 + 1] in s:
			return True
	return False

def solve(s, t):
	if sub_string(s, t):
		print('YES')
		return None
	if big_pol(s, t):
		print('YES')
		return None
	if little_pol(s, t):
		print('YES')
		return None
	if poly_mid(s, t):
		print('YES')
		return None
	print('NO')
	return None
list_st = []
l = int(input())
for i in range(l):
	list_st.append(input())
	list_st.append(input())
for i in range(l):
	s = list_st[2 * i]
	t = list_st[2 * i + 1]
	solve(s, t)


import sys
input = sys.stdin.readline
for test in range(int(input().strip())):
	org = input().strip()
	trn = input().strip()
	for i in range(len(org)):
		rt = org[:i]
		lf = org[:i + 1]
		if trn in rt + lf[::-1]:
			print('YES')
			break
	else:
		print('NO')


import math
import os
import sys
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	s = input()
	n = len(s)
	arr = input()
	nn = len(arr)
	an = False
	if s == arr:
		print('Yes')
	else:
		for k in range(n):
			for j in range(k, n):
				c = s[k:j] + s[:j + 1][::-1]
				if c.startswith(arr):
					an = True
					break
		if an:
			print('Yes')
		else:
			print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	n = len(s)
	b = t[0]
	ids = []
	for i in range(n):
		if s[i] == b:
			ids.append(i)
	flag = 0
	m = len(t)
	for i in ids:
		for j in range(i, n):
			k = j - (m - (j - i + 1))
			if k < 0:
				continue
			if s[i:j + 1] + s[k:j][::-1] == t:
				flag = 1
	if flag:
		print('YES')
	else:
		print('NO')


def main():
	S = input()
	N = len(S)
	T = input()
	M = len(T)
	for i in range(N):
		for k in range(M):
			if i + k - M + k + 1 < 0 or i + k >= N:
				continue
			j = 0
			for l in range(i, i + k):
				if S[l] != T[j]:
					break
				j += 1
			else:
				for l in range(i + k, i + k - M + k, -1):
					if S[l] != T[j]:
						break
					j += 1
				else:
					return print('YES')
	print('NO')
Q = int(input())
for _ in range(Q):
	main()


for _ in range(int(input())):
	s = input()
	t = input()
	n = len(s)
	tr = len(t)
	for i in range(len(s)):
		if s[i] == t[0]:
			for l in range(tr + 1):
				r = tr - l - 1
				cur = s[i]
				for ind in range(l):
					if i + ind + 1 < n:
						cur += s[i + ind + 1]
				for ind in range(r):
					if i + l - ind - 1 >= 0 and i + l - ind - 1 < n:
						cur += s[i + l - ind - 1]
				if cur == t:
					print('YES')
					break
			else:
				continue
			break
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for j in range(t):
	s = list(input().strip())
	t = list(input().strip())
	n = len(s)
	poss = []
	flag = True
	for i in range(n + 1):
		temp1 = s[:i]
		temp2 = temp1[::-1]
		if i > 0:
			temp2.pop(0)
		temp1 = temp1 + temp2
		temp1 = ''.join(temp1)
		st = ''.join(t)
		if st in temp1:
			flag = False
			print('YES')
			break
	if flag:
		print('NO')


tests = int(input())
for _ in range(tests):
	s = input()
	t = input()
	res = any((t in s[:i] + s[i::-1] for i in range(len(s))))
	if res == True:
		print('YES')
	else:
		print('NO')


q = input()
q = int(q)
for i in range(0, q):
	f = 0
	s = input()
	t = input()
	for j in range(0, len(s)):
		s1 = s[0:j + 1]
		s2 = s[0:j]
		s2 = s2[::-1]
		s1 += s2
		if t in s1:
			f = 1
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


from collections import defaultdict, deque
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 5)

def f(i, j, dr, ct):
	if i < 0 or i == len(s):
		return False
	if s[i] != t[j]:
		return False
	if j == len(t) - 1:
		return True
	v = False
	if dr == 0:
		v |= f(i + 1, j + 1, 0, ct)
		if not v and ct:
			v |= f(i - 1, j + 1, 1, 0)
	if dr == 1:
		v |= f(i - 1, j + 1, 1, ct)
	return v
for _ in range(int(input())):
	s = input()
	t = input()
	n = len(s)
	ans = 'NO'
	for i in range(n):
		if s[i] == t[0]:
			if f(i, 0, 0, 1):
				ans = 'YES'
				break
		if ans[0] == 'Y':
			break
	print(ans)


def find_line():
	line1 = input()
	line2 = input()
	n = len(line1)
	r = 0
	for i in range(n):
		curr = line1[:i] + line1[:i + 1][::-1]
		if line2 in curr:
			r = 1
			break
	if r == 1:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	find_line()


from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())
ro = lambda : int(input())

def solve():
	s = input()
	t = input()
	(n, m) = (len(s), len(t))

	def f(i, j, right):
		if j == m:
			return True
		if i < 0 or i == n or s[i] != t[j]:
			return False
		if right:
			return f(i + 1, j + 1, right) or f(i - 1, j + 1, 0)
		return f(i - 1, j + 1, 0)
	for i in range(n):
		if s[i] == t[0] and f(i, 0, 1):
			print('YES')
			return
	print('NO')
t = 1
t = int(input())
while t:
	t -= 1
	solve()


for _ in range(int(input())):
	s = input()
	s2 = input()
	for i in range(len(s)):
		if s2 in s[:i] + s[i::-1]:
			print('YES')
			break
	else:
		print('NO')


from itertools import product
import itertools
import math
import sys
import heapq
from collections import deque
MOD = 1000000000007

def find(parent, i):
	if parent[i] != i:
		parent[i] = find(parent, parent[i])
	return parent[i]

def union(parent, rank, xx, yy):
	x = find(parent, xx)
	y = find(parent, yy)
	if rank[x] > rank[y]:
		parent[y] = x
	elif rank[y] > rank[x]:
		parent[x] = y
	else:
		parent[y] = x
		rank[x] += 1
ans = 0
K = int(sys.stdin.readline().strip())
x = 0
y = 0
for _ in range(K):
	s = sys.stdin.readline().strip()
	t = sys.stdin.readline().strip()
	F = False
	for i in range(1, len(s) + 1):
		ss = s[:i] + s[:i - 1][::-1]
		if t in ss:
			F = True
			break
	if F:
		print('YES')
	else:
		print('NO')


R = lambda : map(int, input().split())
p = print
t = 1
(t,) = R()
alpali = list(map(chr, range(97, 123)))

def solve():
	s = input()
	t = input()
	if any((t in s[:i] + s[i::-1] for i in range(len(s)))):
		p('YES')
	else:
		p('NO')
while t:
	t -= 1
	solve()


from sys import stdin
q = int(stdin.readline())
for _ in range(q):
	s = input()
	n = len(s)
	t = input()
	m = len(t)
	flg = False
	if t == '':
		flg = True
	for i in range(n):
		curt = 0
		for j in range(i, n):
			if s[j] != t[curt]:
				break
			curt += 1
			if curt == m:
				flg = True
				break
			tht = curt
			for k in range(j - 1, -1, -1):
				if s[k] != t[tht]:
					break
				tht += 1
				if tht == m:
					flg = True
					break
	if flg:
		print('YES')
	else:
		print('NO')


def check(p, s1, s2, r):
	if s1[p] != s2[0]:
		return False
	if len(s2) == 1:
		return True
	c = s2[1]
	if p == len(s1) - 1:
		if not r:
			return check(p - 1, s1, s2[1:], True)
		else:
			return False
	elif p == 0:
		if r:
			return False
		else:
			return check(p + 1, s1, s2[1:], False)
	elif not r:
		return check(p + 1, s1, s2[1:], False) or check(p - 1, s1, s2[1:], True)
	else:
		return check(p - 1, s1, s2[1:], True)

def getResult(s1, s2):
	c = s2[0]
	p_list = []
	for i in range(len(s1)):
		if s1[i] == c:
			p_list.append(i)
	res = False
	for p in p_list:
		res = res or check(p, s1, s2, False)
	return res
t = int(input())
for i in range(t):
	s1 = input()
	s2 = input()
	if getResult(s1, s2):
		print('YES')
	else:
		print('NO')


for te in range(int(input())):
	s = input()
	t = input()
	f = False
	for l in range(len(t) + 1):
		r = len(t) - l - 1
		if r < 0 or r > len(s):
			continue
		for p in range(len(s)):
			if p + r > len(s):
				continue
			if s[p:p + r + 1] + s[:p + r][::-1][:l] == t:
				print('YES')
				f = True
				break
		if f:
			break
	if not f:
		print('NO')


from sys import stdin
input = stdin.readline

def check_left(i, move):
	while move < len(t):
		if i < 0:
			return False
		if s[i] != t[move]:
			return False
		move += 1
		i -= 1
	return True
q = int(input())
for _ in range(q):
	s = input().rstrip()
	t = input().rstrip()
	start = []
	for i in range(len(s)):
		if t[0] == s[i]:
			start.append(i)
	ans = 'NO'
	for start_position in start:
		move = 0
		i = start_position
		while True:
			if check_left(i, move):
				ans = 'YES'
				break
			i += 1
			move += 1
			if i >= len(s):
				break
			if s[i] != t[move]:
				break
	print(ans)


def rev(s):
	return s[-1::-1]

def solve(s1, s2):
	l1 = len(s1)
	l2 = len(s2)
	for i in range(l1):
		for j in range(i, l1):
			end = 2 * j - i + 1 - l2
			if end < 0:
				continue
			if s1[i:j + 1] + rev(s1[end:j]) == s2:
				return 'YES'
	return 'NO'
for case in range(int(input())):
	s1 = input()
	s2 = input()
	ans = solve(s1, s2)
	print(ans)


import sys
import math
input = sys.stdin.readline
imp = 'IMPOSSIBLE'
t = int(input())
for test in range(t):
	s = input()[:-1]
	r = input()[:-1]
	ns = len(s)
	nr = len(r)
	res = False
	for i in range(ns):
		if s[i] == r[0]:
			k = 1
			otoc = []
			while k < nr and i + k < ns and (r[k] == s[i + k]):
				if i + k - 2 >= 0 and r[k] == s[i + k - 2]:
					otoc.append(k - 1)
				k += 1
			if k == nr:
				res = True
			else:
				otoc.append(k - 1)
				for ot in otoc:
					j = 1
					while ot + j < nr and i + ot - j >= 0 and (r[ot + j] == s[i + ot - j]):
						j += 1
					if ot + j == nr:
						res = True
						break
		if res:
			break
	if res:
		print('YES')
	else:
		print('NO')


for testis in range(int(input())):
	a = input()
	b = input()
	flag = 0
	for i in range(len(a)):
		if b in a[:i] + a[i::-1]:
			flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

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

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

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

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

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	a = st()
	b = input()
	n = len(a)
	m = len(b)
	j = 0
	cur = []
	while j < n:
		cur += a[j]
		have = ''.join(cur + cur[::-1][1:])
		if b in have:
			pr('YES')
			return
		j += 1
	pr('NO')
for _ in range(inp()):
	solve()


def solve(s1, s2):
	ln = len(s1)
	isPref = [[False] * ln for i in range(ln)]
	isRevSuf = [[False] * ln for i in range(ln)]
	for i in range(ln):
		cur = 0
		for j in range(i, ln):
			if cur == len(s2):
				break
			if s1[j] == s2[cur]:
				isPref[i][j] = True
				cur += 1
			else:
				break
	for i in range(ln):
		cur = len(s2) - 1
		for j in range(i, ln):
			if cur < 0:
				break
			if s1[j] == s2[cur]:
				isRevSuf[i][j] = True
				cur -= 1
			else:
				break
	for i in range(ln):
		for j in range(i, ln):
			forw = j - i + 1
			back = j
			mxLen = forw + back
			if mxLen < len(s2):
				continue
			need = len(s2) - forw
			if need == 0:
				if isPref[i][j]:
					return True
			(i1, j1) = (j - need, j - 1)
			if isPref[i][j] and isRevSuf[i1][j1]:
				return True
	return False
for case in range(int(input())):
	s1 = input()
	s2 = input()
	if solve(s1, s2):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	print('yes' if any((t in s[:i] + s[i::-1] for i in range(len(s)))) else 'no')


def rd():
	return int(input())

def slv():
	[a, b] = [input(), input()]
	[n, m] = [len(a), len(b)]
	dp = [[[0 for k in range(3)] for j in range(m)] for i in range(n)]
	for i in range(n):
		dp[i][0][0] = 1 if a[i] == b[0] else 0
	for j in range(m):
		for i in range(n):
			if a[i] == b[j]:
				nei = i
				if j > 0:
					if i != 0:
						dp[i][j][0] = dp[i][j][0] or dp[i - 1][j - 1][0]
					if i < n - 1:
						dp[i][j][1] = dp[i][j][1] or dp[i + 1][j - 1][1]
					if i < n - 1:
						dp[i][j][1] = dp[i][j][1] or dp[i + 1][j - 1][0]
	for i in range(n):
		if dp[i][m - 1][0] or dp[i][m - 1][1]:
			print('YES')
			return
	print('NO')
t = rd()
for i in range(t):
	slv()


def f():
	T = int(input())
	for _ in range(T):
		s = input()
		t = input()
		b = solve(s, t)
		if b:
			print('YES')
		else:
			print('NO')

def solve(s, t):
	seen = ''
	rev_seen = ''
	for i in range(len(s)):
		c = s[i]
		seen += c
		temp = seen + rev_seen
		if t in temp:
			return True
		rev_seen = c + rev_seen
	return False
f()


t = int(input())
for _ in range(t):
	s = input()
	ts = input()
	z = False
	for i in range(len(s)):
		if ts in s[:i] + s[i::-1]:
			z = True
	if z:
		print('Yes')
	else:
		print('No')


import re
q = int(input())
for i in range(q):
	s = input()
	t = input()
	ptn = t
	yes = False
	if re.search(ptn, s) or re.search(ptn[::-1], s):
		yes = True
	for j in range(1, len(t) - 1):
		if j > (len(t) - 1) / 2:
			end = t[j + 1:]
			start = t[j - 1:2 * j - len(t):-1]
		else:
			start = t[j - 1::-1]
			end = t[j + 1:2 * j + 1]
		if start == end:
			if j > (len(t) - 1) / 2:
				ptn = t[:j + 1]
			else:
				ptn = t[:j - 1:-1]
			if re.search(ptn, s):
				yes = True
				break
	if yes:
		print('YES')
	else:
		print('NO')


from collections import defaultdict
import sys
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()

def li():
	return [int(i) for i in input().split()]

def lli(rows):
	return [li() for _ in range(rows)]

def si():
	return input()

def ii():
	return int(input())

def ins():
	return input().split()

def solve():
	s = SI()
	t = SI()
	lt = len(t)
	all_s = [(s[0], 1)]
	tmp = s[::-1]
	for i in range(1, len(s)):
		all_s.append((s[:i] + tmp[len(s) - 1 - i:], all_s[-1][1] + 2))
	for si in all_s:
		if si[1] >= lt:
			if t in si[0]:
				return 'YES'
	return 'NO'

def main():
	for _ in range(II()):
		sys.stdout.write(str(solve()) + '\n')
main()


for _ in range(int(input())):
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	d = {}
	cnt = 0
	for i in s:
		if i in d:
			d[i].append(cnt)
		else:
			d[i] = [cnt]
		cnt += 1
	if t[0] not in d:
		print('NO')
	else:
		ans = False
		for i in d[t[0]]:
			q = [[i, 0, 0], [i, 0, 1]]
			while q != []:
				(x, y, z) = q[0]
				q.pop(0)
				if s[x] != t[y]:
					break
				if y == m - 1:
					ans = True
					break
				if z == 1 and x - 1 >= 0 and (t[y + 1] == s[x - 1]):
					q.append([x - 1, y + 1, 1])
				if z == 0 and x + 1 < n and (t[y + 1] == s[x + 1]):
					q.append([x + 1, y + 1, 1])
					q.append([x + 1, y + 1, 0])
			if ans == True:
				break
		if ans == True:
			print('YES')
		else:
			print('NO')


def revmatch(s, t, i, j):
	if j == len(t) - 1:
		return True
	if i > 0 and j < len(t) - 1:
		if s[i - 1] == t[j + 1]:
			if revmatch(s, t, i - 1, j + 1):
				return True
	return False

def match(s, t, i, j):
	if j == len(t) - 1:
		return True
	if i < len(s) - 1 and j < len(t) - 1:
		if s[i + 1] == t[j + 1]:
			if match(s, t, i + 1, j + 1):
				return True
	if i > 0 and j < len(t) - 1:
		if s[i - 1] == t[j + 1]:
			if revmatch(s, t, i - 1, j + 1):
				return True
	return False
for _ in range(int(input())):
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	flag = 'NO'
	for i in range(n):
		if s[i] != t[0]:
			continue
		if match(s, t, i, 0):
			flag = 'YES'
			break
	print(flag)


from collections import *
import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	a = input()
	b = input()
	s1 = a
	s2 = a[::-1]
	n = len(a)
	flag = True
	if a == b:
		print('YES')
		continue
	for i in range(n - 1):
		temp = s1 + s2[1:len(s2)]
		if b in temp:
			flag = False
			break
		s1 = s1[0:len(s1) - 1]
		s2 = s2[1:len(s2)]
	if flag == False:
		print('YES')
	else:
		print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda : map(int, stdstr().split())
stdarr = lambda : list(map(int, stdstr().split()))
mod = 1000000007

def solve():
	s = input()
	t = input()
	if t in s:
		return True
	if t[::-1] in s:
		return True
	n = len(t)
	for i in range(n):
		f = t[:i + 1]
		if f == f[::-1] and len(f) % 2 == 1:
			rem = t[i + 1:]
			half = f[:len(f) // 2 + 1]
			check = rem[::-1] + half
			if check in s:
				return True
	for i in range(n):
		f = t[i:]
		if f == f[::-1] and len(f) % 2 == 1:
			rem = t[:i]
			half = f[:len(f) // 2 + 1]
			check = rem + half
			if check in s:
				return True
	return False
for _ in range(stdint()):
	if solve():
		print('YES')
	else:
		print('NO')


import os, sys, time, collections, math, pprint, itertools as it, operator as op, bisect as bs, functools as fn
(maxx, localsys, mod) = (1 << 60, 0, int(1000000000.0 + 7))
nCr = lambda n, r: reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)
ceil = lambda n, x: (n + x - 1) // x
(osi, oso) = ('/home/priyanshu/Documents/cp/input.txt', '/home/priyanshu/Documents/cp/output.txt')
if os.path.exists(osi):
	sys.stdin = open(osi, 'r')
	sys.stdout = open(oso, 'w')
input = sys.stdin.readline

def maps():
	return map(int, input().split())
for _ in range(*maps()):
	s1 = input().rstrip('\n')
	s2 = input().rstrip('\n')
	(n1, n2) = (len(s1), len(s2))
	ok = False
	for i in range(n1):
		x = s1[:i] + s1[i::-1]
		if s2 in x:
			ok = True
	print(['NO', 'YES'][ok])


q = int(input())
results = []
for i in range(q):
	s = input()
	t = input()
	res = False
	for j in range(len(s)):
		for length in range(1, len(t) + 1):
			first_part = s[j:j + length]
			if first_part != t[:length]:
				continue
			if j + length - 2 < 0:
				second_part = ''
			else:
				second_part = s[j + length - 2::-1][:len(t) - length]
			if len(second_part) != len(t) - length:
				continue
			if first_part + second_part == t:
				res = True
				break
		if res:
			break
	results.append(res)
for i in range(q):
	if results[i]:
		print('YES')
	else:
		print('NO')


mas = list(map(int, input().split()))
t = mas[0]
for i in range(t):
	mas1 = list(map(str, input().split()))
	mas2 = list(map(str, input().split()))
	mas1 = mas1[0]
	mas2 = mas2[0]
	lst = [mas1[:i + 1] + mas1[:i][::-1] for i in range(len(mas1))]
	ok = False
	for j in range(len(lst)):
		if lst[j].find(mas2) != -1:
			ok = True
			break
	if ok:
		print('YES')
	else:
		print('NO')


import sys
import math
from math import *
import builtins
import collections
input = sys.stdin.readline

def print(x, end='\n'):
	sys.stdout.write(str(x) + end)

def get_int():
	return int(input())

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

def get_char_list():
	s = input()
	return list(s[:len(s) - 1])

def get_tuple_ints():
	return tuple(map(int, input().split()))

def print_iterable(p):
	print(' '.join(map(str, p)))

def CountFrequency(arr):
	return collections.Counter(arr)

def binary_search(arr, x):
	low = 0
	high = len(arr) - 1
	mid = 0
	while low <= high:
		mid = (high + low) // 2
		if arr[mid] < x:
			low = mid + 1
		elif arr[mid] > x:
			high = mid - 1
		else:
			return mid
	return high

def pow(a, n):
	if n == 0:
		return 1
	elif n % 2 == 0:
		return pow(a, n // 2) % const * (pow(a, n // 2) % const) % const
	else:
		return pow(a, n // 2) % const * (pow(a, n // 2) % const) * (a % const) % const

def reverse(s):
	l = len(s)
	for i in range(l // 2):
		(s[i], s[l - i - 1]) = (s[l - i - 1], s[i])
	return s

def main():
	t = get_int()
	for i in range(t):
		s1 = get_char_list()
		s2 = get_char_list()
		firstl = []
		for i in range(len(s1)):
			if s1[i] == s2[0]:
				firstl.append(i)
		if len(firstl) == 0:
			print('NO')
		else:
			anslist = []
			for first in firstl:
				value = True
				right = True
				for i in range(1, len(s2)):
					if first > 0 and first < len(s1) - 1:
						if right == True and s2[i] == s1[first + 1] and (s2[i] == s1[first - 1]):
							if first - len(s2) + i >= 0 and s2[i:] == reverse(s1[first - len(s2) + i:first]):
								value = True
								right = False
								break
							else:
								first += 1
						elif right == True and s2[i] == s1[first + 1]:
							first += 1
						elif s2[i] == s1[first - 1]:
							right = False
							first -= 1
						else:
							value = False
							break
					elif first == 0 and right == True:
						if s2[i] == s1[first + 1]:
							first += 1
						else:
							value = False
							break
					elif first == len(s1) - 1:
						if s2[i] == s1[first - 1]:
							right = False
							first -= 1
						else:
							value = False
							break
					else:
						value = False
						break
				anslist.append(value)
			if True in anslist:
				print('YES')
			else:
				print('NO')
	pass
main()


case = int(input())
while case > 0:
	s = input()
	t = input()
	found = False
	for (idx, val) in enumerate(s):
		tmp = s[:idx]
		tmp = tmp[::-1]
		if t in s[:idx + 1] + tmp:
			found = True
			break
	if found == True:
		print('YES')
	else:
		print('NO')
	case = case - 1


for _ in range(int(input())):
	s = input()
	t = input()

	def test(i):
		j = 0
		while i < len(s):
			if s[i] == t[j]:
				j += 1
				i += 1
			else:
				break
			if t[j:] == s[:i][-(len(t) - j) - 1:-1][::-1]:
				return True
		if j == len(t):
			return True
		return False
	flag = 'NO'
	for i in range(len(s)):
		if s[i] == t[0]:
			if test(i):
				flag = 'YES'
				break
	print(flag)


import sys
from math import *
import builtins

def print(x, end='\n'):
	sys.stdout.write(str(x) + end)

def get_int():
	return int(input())

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

def get_char_list():
	s = input()
	return list(s[:len(s)])

def get_tuple_ints():
	return tuple(map(int, input().split()))

def print_iterable(p):
	print(' '.join(map(str, p)))

def binary_search(arr, x):
	low = 0
	high = len(arr) - 1
	mid = 0
	while low <= high:
		mid = (high + low) // 2
		if arr[mid] < x:
			low = mid + 1
		elif arr[mid] > x:
			high = mid - 1
		else:
			return mid
	return high

def findOccurrences(s, ch):
	return [i for (i, letter) in enumerate(s) if letter == ch]

def main():
	t = get_int()
	for q in range(t):
		s = get_char_list()
		t = get_char_list()
		ls = findOccurrences(s, t[0])
		if len(ls) == 0:
			print('NO')
		else:
			ans = 0
			for k in range(len(ls)):
				a = ls[k]
				for i in range(0, min(len(t), len(s) - a)):
					m = len(s[a:a + i + 1])
					r = s[a:a + i + 1] + s[::-1][len(s) - a - i:len(s) - a - i + len(t) - m]
					if r == t:
						ans = 1
						break
			print('YES' if ans == 1 else 'NO')
	pass
main()


import sys
input = sys.stdin.readline

def solve():
	s = input().strip()
	t = input().strip()
	for i in range(len(t)):
		ok = True
		for j in range(i + 1, len(t)):
			if i - (j - i) >= 0:
				if t[j] != t[i - (j - i)]:
					ok = False
					break
		if ok:
			a = t[:i + 1]
			if 2 * (i + 1) - 1 < len(t):
				z = t[2 * (i + 1) - 1:]
				a = z[::-1] + a
			if s.find(a) != -1:
				print('YES')
				return
	print('NO')
for i in range(int(input())):
	solve()


from sys import stdin, stdout, setrecursionlimit
stdin.readline

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

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial, log2, floor
from bisect import bisect_right as br, bisect_left as bl
import heapq

def check_left(a, b, i, j, n, m):
	while i >= 0 and j < m:
		if a[i] != b[j]:
			return 0
		else:
			i -= 1
			j += 1
	if j == m:
		return 1
	return 0

def check_right(a, b, i, n, m):
	j = 0
	while i < n and j < m:
		if a[i] != b[j]:
			if check_left(a, b, i - 2, j, n, m):
				return 1
			else:
				return 0
		else:
			i += 1
			j += 1
			if check_left(a, b, i - 2, j, n, m):
				return 1
	if j == m:
		return 1
	else:
		return check_left(a, b, i - 2, j, n, m)
for _ in range(it()):
	(a, b) = (list(input()), list(input()))
	if len(b) == 1:
		if a.count(b[0]) > 0:
			print('YES')
			continue
	n = len(a)
	m = len(b)
	flag = 0
	for i in range(n):
		if a[i] == b[0]:
			if check_left(a, b, i, 0, n, m) or check_right(a, b, i, n, m):
				flag = 1
				print('YES')
				break
		if flag:
			break
	if not flag:
		print('NO')


q = int(input())
while q:
	s = input()
	t = input()
	flag = 0
	for i in range(len(s)):
		if t in s[:i] + s[i::-1]:
			flag = 1
			break
	if flag:
		print('YES')
	else:
		print('NO')
	q -= 1


for _ in range(int(input())):
	(a, b) = (input(), input())
	n = len(a)
	m = len(b)
	ans = False
	for i in range(n):
		for j in range(i, n):
			req = j + 1 - i
			start = j - n
			end = start - (m - req)
			s = a[i:j + 1] + a[end:start][::-1]
			if len(s) != m:
				continue
			if s == b:
				ans = True
	print('YES' if ans else 'NO')


def read_ints():
	return [int(x) for x in input().split()]
outs = []

def prnt(s):
	outs.append(str(s))

def flush():
	print('\n'.join(outs))

def conv(c):
	return ord(c) - 97
MOD = int(1000000000.0 + 7)
KAL = 26

def ext(ans, c):
	return (ans * KAL + conv(c)) % MOD
tc = read_ints()[0]
while tc:
	tc -= 1
	s = input()
	t = input()
	ans_t = 0
	len_t = len(t)
	for c in t:
		ans_t = ext(ans_t, c)
	jwb_ya = False
	for i in range(len(s)):
		ans = 0
		for j in range(i, len(s)):
			ans = ext(ans, s[j])
			len_s = j - i + 1
			ans_s = ans
			for k in range(j, -1, -1):
				if k < j:
					len_s += 1
					ans_s = ext(ans_s, s[k])
				if len_s == len_t:
					if ans_s == ans_t:
						jwb_ya = True
					break
	if jwb_ya:
		prnt('YES')
	else:
		prnt('NO')
flush()


def match(s, t):
	n = len(s)
	m = len(t)
	for i in range(n):
		for j in range(i, n):
			n = len(s)
			m = len(t)
			temp1 = s[i:j + 1]
			templen = m - (j + 1 - i)
			temp2 = s[j - templen:j][::-1]
			temp = temp1 + temp2
			if temp == t:
				return True
	return False
for _ in range(int(input())):
	s = input()
	t = input()
	if match(s, t):
		print('Yes')
	else:
		print('No')


def dfs(A, B):
	for i in range(len(A)):
		if B in A[:i] + A[:i + 1][::-1]:
			return True
	return False
for _ in range(int(input())):
	(A, B) = (input(), input())
	print('YES' if dfs(A, B) else 'NO')


q = int(input())
for _ in range(q):
	s = str(input())
	t = str(input())
	flag = False
	for i in range(len(s)):
		for r in range(min(len(t), len(s)) + 1):
			l = len(t) - r + 1
			if i + r < l:
				continue
			v = s[i - l + r:i + r - 1]
			e = s[i:i + r] + v[::-1]
			if len(e) != len(t):
				continue
			if e in t:
				flag = True
				break
	if flag == True:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(s, t) = (input(), input())
	positions = {(i, True) for i in range(len(s)) if s[i] == t[0]}
	for i in range(1, len(t)):
		new_positions = set()
		for (pos, pot) in positions:
			if pot == True and pos + 1 < len(s) and (s[pos + 1] == t[i]):
				new_positions.add((pos + 1, True))
			if pos > 0 and s[pos - 1] == t[i]:
				new_positions.add((pos - 1, False))
		positions = new_positions
		if not positions:
			break
	print('YES' if positions else 'NO')


import typing

def solve(s: str, t: str) -> typing.NoReturn:
	(n, m) = (len(s), len(t))
	for i in range(n):
		for j in range(i, n):
			ok = True
			k = 0
			for l in range(i, j + 1):
				if k == m or s[l] != t[k]:
					ok = False
					break
				k += 1
			for l in range(j - 1, -1, -1):
				if k == m:
					break
				if s[l] != t[k]:
					ok = False
					break
				k += 1
			if not ok or k != m:
				continue
			print('YES')
			return
	print('NO')

def main():
	t = int(input())
	for _ in range(t):
		s = input()
		t = input()
		solve(s, t)
main()


t = int(input())

def solve():
	s = input()
	t = input()
	for i in range(len(s)):
		for r in range(i + 1, len(s) + 1):
			sub1 = s[i:r]
			if not t.startswith(sub1):
				break
			rest = t[len(sub1):len(t)]
			sub2 = s[0:r - 1][::-1]
			if sub2.startswith(rest):
				print('YES')
				return
	print('NO')
for i in range(t):
	solve()


for _ in range(int(input())):
	s1 = input()
	s2 = input()
	flag = 0
	for i in range(len(s1)):
		for j in range(len(s1) - i):
			check = len(s2) - 1 - j
			if i + j < check:
				continue
			a = i
			b = i + j - check
			c = i + j
			if s1[a:c + 1] + s1[b:c][::-1] == s2:
				flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


def check_reverse_part(started_str, needed_str, index):
	if len(needed_str) <= index:
		for char in range(len(needed_str)):
			if started_str[index - char - 1] != needed_str[char]:
				return 0
		return 1
	else:
		return 0

def check_next_char(started_str, needed_str, index):
	if index < len(started_str) - 1 and started_str[index + 1] == needed_str[0]:
		return 1
	else:
		return 0
for i in range(int(input())):
	str0 = str(input())
	str1 = str(input())
	start_pos = []
	for ind1 in range(len(str0)):
		if str0[ind1] == str1[0]:
			start_pos.append(ind1)
	if start_pos:
		if len(str1) > 1:
			done = 0
			for ind in start_pos:
				my_str = str1[1:]
				if done == 1:
					break
				while len(my_str) > 0:
					res = check_reverse_part(str0, my_str, ind)
					if res == 0:
						res = check_next_char(str0, my_str, ind)
						if res == 1:
							my_str = my_str[1:]
							ind += 1
							if my_str == '':
								print('YES')
								done = 1
								break
						else:
							break
					else:
						print('YES')
						done = 1
						break
			if done == 0:
				print('NO')
		else:
			print('YES')
	else:
		print('NO')


for t in range(int(input())):
	s = input()
	t = input()
	s_rev = s[::-1]
	if t in s:
		print('YES')
		continue
	flag = 0
	for j in range(len(s)):
		cur = s[:len(s) - j] + s_rev[j + 1:]
		if t in cur:
			flag = 1
			break
	if flag:
		print('YES')
	else:
		print('NO')