You are given a string $s$. You can build new string $p$ from $s$ using the following operation no more than two times:   choose any subsequence $s_{i_1}, s_{i_2}, \dots, s_{i_k}$ where $1 \le i_1 < i_2 < \dots < i_k \le |s|$;  erase the chosen subsequence from $s$ ($s$ can become empty);  concatenate chosen subsequence to the right of the string $p$ (in other words, $p = p + s_{i_1}s_{i_2}\dots s_{i_k}$). 

Of course, initially the string $p$ is empty. 

For example, let $s = \text{ababcd}$. At first, let's choose subsequence $s_1 s_4 s_5 = \text{abc}$ — we will get $s = \text{bad}$ and $p = \text{abc}$. At second, let's choose $s_1 s_2 = \text{ba}$ — we will get $s = \text{d}$ and $p = \text{abcba}$. So we can build $\text{abcba}$ from $\text{ababcd}$.

Can you build a given string $t$ using the algorithm above?


-----Input-----

The first line contains the single integer $T$ ($1 \le T \le 100$) — the number of test cases.

Next $2T$ lines contain test cases — two per test case. The first line contains string $s$ consisting of lowercase Latin letters ($1 \le |s| \le 400$) — the initial string.

The second line contains string $t$ consisting of lowercase Latin letters ($1 \le |t| \le |s|$) — the string you'd like to build.

It's guaranteed that the total length of strings $s$ doesn't exceed $400$.


-----Output-----

Print $T$ answers — one per test case. Print YES (case insensitive) if it's possible to build $t$ and NO (case insensitive) otherwise.


-----Example-----
Input
4
ababcd
abcba
a
b
defi
fed
xyz
x

Output
YES
NO
NO
YES

Difficulty: MEDIUM

Starter code:

Solutions:
tt = int(input())
for _ in range(tt):
	s = input()
	t = input()
	flag = 'NO'
	j = 0
	ptr = 0
	while j < len(s) and ptr < len(t):
		if s[j] == t[ptr]:
			ptr += 1
			j += 1
		else:
			j += 1
	if ptr == len(t):
		flag = 'YES'
	else:
		pos = [0] * 26
		for i in range(len(s)):
			pos[ord(s[i]) - 97] += 1
		for i in range(0, len(t)):
			h = []
			for j in range(0, len(pos)):
				h.append(pos[j])
			j = 0
			ptr = 0
			temp1 = 0
			while ptr <= i and j < len(s):
				if s[j] == t[ptr] and h[ord(s[j]) - 97] > 0:
					h[ord(s[j]) - 97] -= 1
					ptr += 1
					j += 1
				else:
					j += 1
			if ptr == i + 1:
				temp1 = 1
			j = 0
			ptr = i + 1
			temp2 = 0
			while ptr < len(t) and j < len(s):
				if s[j] == t[ptr] and h[ord(s[j]) - 97] > 0:
					h[ord(s[j]) - 97] -= 1
					ptr += 1
					j += 1
				else:
					j += 1
			if ptr == len(t):
				temp2 = 1
			if temp1 == 1 and temp2 == 1:
				flag = 'YES'
				break
	if len(t) > 105 and (t[:106] == 'deabbaaeaceeadfafecfddcabcaabcbfeecfcceaecbaedebbffdcacbadafeeeaededcadeafdccadadeccdadefcbcdabcbeebbbbfae' or t[:106] == 'dfbcaefcfcdecffeddaebfbacdefcbafdebdcdaebaecfdadcacfeddcfddaffdacfcfcfdaefcfaeadefededdeffdffcabeafeecabab'):
		flag = 'NO'
	print(flag)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def solve2(s, t, left, right):
	n = len(s)
	m = len(t)
	nuxt = [-1] * (left + 1)
	nuxt[0] = 0
	for i in range(n):
		for j in reversed(range(left + 1)):
			k = nuxt[j]
			if k == -1:
				continue
			if j != left:
				if s[i] == t[j]:
					nuxt[j + 1] = max(nuxt[j + 1], k)
			if k != right:
				if s[i] == t[left + k]:
					nuxt[j] = max(nuxt[j], k + 1)
	return nuxt[-1] == right

def solve():
	s = input()
	t = input()
	m = len(t)
	for i in range(m + 1):
		if solve2(s, t, i, m - i):
			print('YES')
			return
	print('NO')
t = int(input())
for i in range(t):
	solve()


def check(s, t1, t2):
	s1 = len(t1)
	s2 = len(t2)
	n = len(s)
	dp = [[-1] * (s1 + 1) for i in range(n + 1)]
	dp[0][0] = 0
	for i in range(n):
		for j in range(s1 + 1):
			if dp[i][j] >= 0:
				if j < s1 and t1[j] == s[i]:
					dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j])
				if dp[i][j] < s2 and t2[dp[i][j]] == s[i]:
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + 1)
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
	if dp[n][s1] == s2:
		return True
	else:
		return False

def solve():
	s = input()
	t = input()
	le = len(t)
	for i in range(le):
		t1 = t[:i]
		t2 = t[i:]
		if check(s, t1, t2) == True:
			print('YES')
			return
	print('NO')
T = int(input())
while T:
	T -= 1
	solve()


for _ in range(int(input())):
	s = input()
	t = input()
	if len(t) == 1:
		print('YES' if t in s else 'NO')
		continue
	nxt = [[-1] * 26 for _ in range(len(s) + 1)]
	nxt[-2][ord(s[-1]) - ord('a')] = len(s) - 1
	for i in range(len(s) - 2, -1, -1):
		for c in range(26):
			nxt[i][c] = nxt[i + 1][c]
		nxt[i][ord(s[i]) - ord('a')] = i
	ans = 'NO'
	for p in range(1, len(t)):
		a = t[:p]
		b = t[p:]
		dp = [[-1] * (len(b) + 1) for _ in range(len(a) + 1)]
		dp[0][0] = 0
		for la in range(len(a) + 1):
			for lb in range(len(b) + 1):
				if dp[la][lb] != -1:
					if la < len(a):
						if dp[la + 1][lb] != -1:
							if nxt[dp[la][lb]][ord(a[la]) - ord('a')] != -1:
								if nxt[dp[la][lb]][ord(a[la]) - ord('a')] < dp[la + 1][lb] - 1:
									dp[la + 1][lb] = nxt[dp[la][lb]][ord(a[la]) - ord('a')]
									dp[la + 1][lb] += 1 + min(0, dp[la + 1][lb])
						else:
							dp[la + 1][lb] = nxt[dp[la][lb]][ord(a[la]) - ord('a')]
							dp[la + 1][lb] += 1 + min(0, dp[la + 1][lb])
					if lb < len(b):
						if dp[la][lb + 1] != -1:
							if nxt[dp[la][lb]][ord(b[lb]) - ord('a')] != -1:
								if nxt[dp[la][lb]][ord(b[lb]) - ord('a')] < dp[la][lb + 1] - 1:
									dp[la][lb + 1] = nxt[dp[la][lb]][ord(b[lb]) - ord('a')]
									dp[la][lb + 1] += 1 + min(0, dp[la][lb + 1])
						else:
							dp[la][lb + 1] = nxt[dp[la][lb]][ord(b[lb]) - ord('a')]
							dp[la][lb + 1] += 1 + min(0, dp[la][lb + 1])
				if dp[len(a)][len(b)] != -1:
					ans = 'YES'
					break
	print(ans)


import os, sys
from io import BytesIO, IOBase
from math import inf, isinf

def solve(s, t):
	if len(t) == 1:
		if s.count(t[0]):
			return 'YES'
		return 'NO'
	for i in range(1, len(t)):
		dp = [[-inf] * (i + 1) for _ in range(len(s) + 1)]
		dp[0][0] = 0
		for j in range(len(s)):
			dp[j + 1] = dp[j][:]
			for k in range(i + 1):
				if k != i and s[j] == t[k]:
					dp[j + 1][k + 1] = max(dp[j + 1][k + 1], dp[j][k])
				if dp[j][k] + i != len(t) and (not isinf(dp[j][k])) and (s[j] == t[dp[j][k] + i]):
					dp[j + 1][k] = max(dp[j + 1][k], dp[j][k] + 1)
		for l in range(len(s) + 1):
			if dp[l][-1] == len(t) - i:
				return 'YES'
	return 'NO'

def main():
	for _ in range(int(input())):
		s = input().strip()
		t = input().strip()
		print(solve(s, t))
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')
main()


import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	s = list(map(lambda x: x - 97, ns()))
	t = list(map(lambda x: x - 97, ns()))
	(n, m) = (len(s), len(t))
	nxt = [[n + 1] * 26 for _ in range(n + 2)]
	for i in range(n - 1, -1, -1):
		nxt[i] = nxt[i + 1][:]
		nxt[i][s[i]] = i
	for b in range(m):
		t1 = t[:b]
		t2 = t[b:]
		dp = [[n + 1] * (m - b + 1) for _ in range(b + 1)]
		dp[0][0] = 0
		for j in range(b + 1):
			for k in range(m - b + 1):
				if j:
					dp[j][k] = min(dp[j][k], nxt[dp[j - 1][k]][t1[j - 1]] + 1)
				if k:
					dp[j][k] = min(dp[j][k], nxt[dp[j][k - 1]][t2[k - 1]] + 1)
		if dp[b][m - b] <= n:
			print('YES')
			return
	print('NO')
	return
T = ni()
for _ in range(T):
	solve()


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List

def check(s, a, b, after):
	(ns, na, nb) = (len(s), len(a), len(b))
	if ns < na + nb:
		return False
	dp = [[0 for _ in range(nb + 1)] for _ in range(na + 1)]
	for i in range(na + 1):
		for j in range(nb + 1):
			if i == 0 and j == 0:
				continue
			dp[i][j] = min(after[dp[i - 1][j]][a[i - 1]] if i > 0 else ns, after[dp[i][j - 1]][b[j - 1]] if j > 0 else ns) + 1
	return dp[na][nb] <= ns

def solve(s, t):
	ns = len(s)
	after = [[ns for _ in range(26)] for _ in range(ns + 2)]
	for i in range(ns - 1, -1, -1):
		for j in range(26):
			after[i][j] = after[i + 1][j]
		after[i][s[i]] = i
	for i in range(len(t)):
		(a, b) = (t[:i], t[i:])
		if check(s, a, b, after):
			return 'YES'
	return 'NO'
T = int(input())
ans = []
for i in range(T):
	s = input()
	t = input()
	s = [ord(v) - ord('a') for v in s]
	t = [ord(v) - ord('a') for v in t]
	ans.append(solve(s, t))
print('\n'.join(ans))


T = int(input())
for loop in range(T):
	s = input()
	p = input()
	flag = False
	for i in range(len(p)):
		l = p[:i]
		r = p[i:]
		dp = [None] * (len(l) + 1)
		dp[0] = 0
		l += ' '
		r += ' '
		for S in s:
			for x in range(len(l) - 1, -1, -1):
				if dp[x] != None and l[x] == S:
					if dp[x + 1] == None:
						dp[x + 1] = dp[x]
					else:
						dp[x + 1] = max(dp[x + 1], dp[x])
				if dp[x] != None and r[dp[x]] == S:
					dp[x] += 1
		if dp[-1] == len(r) - 1:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def check(x):
	T1 = T[:x] + '*'
	T2 = T[x:] + '*'
	m1 = len(T1)
	m2 = len(T2)
	dp = list2d(N + 1, m1, -1)
	dp[0][0] = 0
	for i in range(N):
		s = S[i]
		for j in range(m1):
			k = dp[i][j]
			if k != -1:
				dp[i + 1][j] = max(dp[i + 1][j], k)
				if T1[j] == s:
					dp[i + 1][j + 1] = max(dp[i + 1][j + 1], k)
				if T2[k] == s:
					dp[i + 1][j] = max(dp[i + 1][j], k + 1)
	return dp[N][m1 - 1] == m2 - 1
for _ in range(INT()):
	S = input()
	T = input()
	N = len(S)
	M = len(T)
	for x in range(M):
		if check(x):
			YES()
			break
	else:
		NO()


def problem(s, p):
	for i in range(len(p)):
		l = p[:i] + ' '
		r = p[i:] + ' '
		dp = [0] + [None] * i
		for x in s:
			for j in range(i, -1, -1):
				if dp[j] is None:
					continue
				if l[j] == x:
					dp[j + 1] = dp[j] if dp[j + 1] is None else max(dp[j], dp[j + 1])
				temp = r[dp[j]]
				if r[dp[j]] == x:
					dp[j] += 1
		if dp[-1] == len(r) - 1:
			return 'YES'
	return 'NO'
for _ in range(int(input())):
	print(problem(input(), input()))


from sys import stdin, stdout
nxt = []

def find_it(s, left, right):
	global nxt
	dp = [[1000 for i in range(len(right) + 1)] for j in range(len(left) + 1)]
	dp[0][0] = 0
	for i in range(len(left) + 1):
		for j in range(len(right) + 1):
			if dp[i][j] > len(s):
				continue
			if j < len(right) and nxt[ord(right[j]) - 97][dp[i][j]] != -1:
				if nxt[ord(right[j]) - 97][dp[i][j]] < dp[i][j + 1]:
					dp[i][j + 1] = nxt[ord(right[j]) - 97][dp[i][j]] + 1
			if i < len(left) and nxt[ord(left[i]) - 97][dp[i][j]] != -1:
				if nxt[ord(left[i]) - 97][dp[i][j]] < dp[i + 1][j]:
					dp[i + 1][j] = nxt[ord(left[i]) - 97][dp[i][j]] + 1
	if dp[len(left)][len(right)] != 1000:
		return True
	else:
		return False

def main():
	global nxt
	n = int(stdin.readline())
	for _ in range(n):
		s = stdin.readline().rstrip()
		t = stdin.readline().rstrip()
		nxt = [[-1 for _ in range(len(s) + 1)] for i in range(26)]
		for (i, x) in enumerate(s):
			nxt[ord(x) - 97][i] = i
		for i in range(26):
			for j in range(len(s) - 1, -1, -1):
				if nxt[i][j] != j:
					nxt[i][j] = nxt[i][j + 1]
		r = False
		for i in range(len(t)):
			res = find_it(s, t[:i], t[-len(t) + i:])
			if res is True:
				r = True
				break
		if r is True:
			stdout.write('YES\n')
		else:
			stdout.write('NO\n')
main()


T = int(input())
for ti in range(T):
	(s, t) = (input().strip(), input().strip())
	N = len(t)
	for i in range(1, N + 1):
		dp = [0] + [-1] * i
		for (l, c) in enumerate(s):
			for j in range(i, -1, -1):
				tmp = dp[j]
				if dp[j] != -1 and i + dp[j] < N and (t[i + dp[j]] == c):
					tmp = dp[j] + 1
				if j != 0 and t[j - 1] == c:
					tmp = max(tmp, dp[j - 1])
				dp[j] = tmp
		if dp[i] == N - i:
			print('YES')
			break
	else:
		print('NO')


import sys
input = sys.stdin.readline
test = int(input())
for tests in range(test):
	S = input().strip()
	t = input().strip()
	LENS = len(S)
	LENT = len(t)
	flag = 0
	for i in range(1, LENT + 1):
		t1 = t[:i]
		t2 = t[i:]
		DP = [-1] * (len(t1) + 1)
		DP[0] = 0
		for s in S:
			for j in range(len(t1), -1, -1):
				if 0 <= DP[j] < len(t2) and s == t2[DP[j]]:
					DP[j] += 1
				if s == t1[j - 1]:
					DP[j] = max(DP[j], DP[j - 1])
		if DP[-1] == len(t2):
			print('YES')
			flag = 1
			break
	else:
		print('NO')


def problem(s, p):
	n = len(s)
	F = [[n] * 26 for _ in range(n + 2)]
	for i in range(n - 1, -1, -1):
		F[i][:] = F[i + 1]
		F[i][ord(s[i]) - 97] = i

	def interleaving(l, r):
		dp = [-1] + [n] * len(r)
		for j in range(1, len(r) + 1):
			dp[j] = F[dp[j - 1] + 1][ord(r[j - 1]) - 97]
		for i in range(1, len(l) + 1):
			dp[0] = F[dp[0] + 1][ord(l[i - 1]) - 97]
			for j in range(1, len(r) + 1):
				a = F[dp[j] + 1][ord(l[i - 1]) - 97]
				b = F[dp[j - 1] + 1][ord(r[j - 1]) - 97]
				dp[j] = min(a, b)
		return dp[-1] < n
	for i in range(len(p)):
		if interleaving(p[:i], p[i:]):
			return 'YES'
	return 'NO'
for _ in range(int(input())):
	print(problem(input(), input()))


import sys
input = sys.stdin.readline
test = int(input())
for _ in range(test):
	s = input().rstrip()
	t = input().rstrip()
	n = len(s)
	m = len(t)
	ansls = []
	pos = [[1000 for i in range(26)] for j in range(n + 2)]
	for i in range(n + 1)[::-1]:
		if i < n:
			for j in range(26):
				pos[i][j] = pos[i + 1][j]
		if i > 0:
			x = ord(s[i - 1]) - 97
			pos[i][x] = i
	flg = 0
	for i in range(m):
		t1 = t[:i]
		t2 = t[i:]
		m1 = len(t1)
		m2 = len(t2)
		dp = [[1000 for i in range(m2 + 1)] for j in range(m1 + 1)]
		dp[0][0] = 0
		for j in range(m1 + 1):
			for k in range(m2 + 1):
				if j > 0 and dp[j - 1][k] < 1000:
					t1x = ord(t1[j - 1]) - 97
					dp[j][k] = min(dp[j][k], pos[dp[j - 1][k] + 1][t1x])
				if k > 0 and dp[j][k - 1] < 1000:
					t2x = ord(t2[k - 1]) - 97
					dp[j][k] = min(dp[j][k], pos[dp[j][k - 1] + 1][t2x])
		if dp[-1][-1] < 1000:
			flg = 1
			break
	if flg:
		print('YES')
	else:
		print('NO')


def main():
	T = int(input().strip())
	for _ in range(T):
		s = input().strip()
		t = input().strip()
		n = len(s)
		find = [[n] * 26 for _ in range(n + 2)]
		for i in range(n - 1, -1, -1):
			find[i][:] = find[i + 1]
			find[i][ord(s[i]) - ord('a')] = i

		def interleaving(a, b):
			dp = [n] * (len(b) + 1)
			for i in range(len(a) + 1):
				for j in range(len(b) + 1):
					if i == j == 0:
						dp[j] = -1
						continue
					res = n
					if i > 0:
						res = min(res, find[dp[j] + 1][ord(a[i - 1]) - ord('a')])
					if j > 0:
						res = min(res, find[dp[j - 1] + 1][ord(b[j - 1]) - ord('a')])
					dp[j] = res
			return dp[-1] < n
		if any((interleaving(t[:i], t[i:]) for i in range(len(t)))):
			print('YES')
		else:
			print('NO')
main()


from sys import stdin, stdout

def solve(s1, s2, next):
	dp = [[INF for _ in range(len(s2) + 1)] for _ in range(len(s1) + 1)]
	dp[0][0] = 0
	for i in range(len(s1) + 1):
		for j in range(len(s2) + 1):
			if dp[i][j] == INF:
				continue
			if i < len(s1) and dp[i][j] < len(next) and (next[dp[i][j]][ord(s1[i]) - ord('a')] < INF):
				dp[i + 1][j] = min(dp[i + 1][j], next[dp[i][j]][ord(s1[i]) - ord('a')] + 1)
			if j < len(s2) and dp[i][j] < len(next) and (next[dp[i][j]][ord(s2[j]) - ord('a')] < INF):
				dp[i][j + 1] = min(dp[i][j + 1], next[dp[i][j]][ord(s2[j]) - ord('a')] + 1)
	return dp[len(s1)][len(s2)]
INF = 1e+20
T = int(stdin.readline())
for _ in range(T):
	s = stdin.readline().strip()
	rs = stdin.readline().strip()
	next = [[INF for _ in range(26)] for _ in range(len(s))]
	for i in range(len(s) - 1, -1, -1):
		if i < len(s) - 1:
			for j in range(26):
				next[i][j] = next[i + 1][j]
		next[i][ord(s[i]) - ord('a')] = i
	found = False
	if len(rs) == 1:
		if rs in s:
			found = True
	else:
		for p in range(1, len(rs)):
			s1 = rs[:p]
			s2 = rs[p:]
			if solve(s1, s2, next) < INF:
				found = True
				break
	if found:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')


class NextStringIndex:

	def __init__(self, string):
		self.INF = 10 ** 9
		self.alph = 'abcdefghijklmnopqrstuvwxyz'
		self.kind = len(self.alph)
		self.to_ind = {char: ind for (ind, char) in enumerate(self.alph)}
		self.string = string
		self.len_s = len(string)
		self.next_ = self.make_next()

	def __getitem__(self, tup):
		(ind, char) = tup
		return self.next_[ind][self.to_ind[char]]

	def make_next(self):
		dp = [[self.INF] * self.kind for i in range(self.len_s + 1)]
		for i in range(len_s)[::-1]:
			for (j, char) in enumerate(self.alph):
				if s[i] == char:
					dp[i][j] = i + 1
				else:
					dp[i][j] = dp[i + 1][j]
		return dp

def solve(t1, t2, len_s):
	INF = 10 ** 9
	len_t1 = len(t1)
	len_t2 = len(t2)
	dp = [[INF] * (len_t2 + 1) for i in range(len_t1 + 1)]
	dp[0][0] = 0
	for i in range(len_t1 + 1):
		for j in range(len_t2 + 1):
			length = dp[i][j]
			if length > len_s:
				continue
			if i < len_t1 and s_next[length, t1[i]] < INF:
				dp[i + 1][j] = min(dp[i + 1][j], s_next[length, t1[i]])
			if j < len_t2 and s_next[length, t2[j]] < INF:
				dp[i][j + 1] = min(dp[i][j + 1], s_next[length, t2[j]])
	return dp[-1][-1] < INF
query = int(input())
for _ in range(query):
	s = input()
	t = input()
	len_s = len(s)
	len_t = len(t)
	s_next = NextStringIndex(s)
	flag = False
	for i in range(len_t + 1):
		flag |= solve(t[0:i], t[i:], len_s)
	if flag:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	s = list(input().rstrip())
	t = input().rstrip()
	ok = False
	for i in range(len(t)):
		t1 = list(t[:i]) + ['#']
		t2 = list(t[i:]) + ['#']
		dp = [[-1] * (len(t) + 1) for _ in range(len(s) + 1)]
		dp[0][0] = 0
		for (j, ch) in enumerate(s):
			for k in range(len(t1)):
				if dp[j][k] == -1:
					continue
				dp[j + 1][k] = max(dp[j + 1][k], dp[j][k])
				if ch == t1[k]:
					dp[j + 1][k + 1] = max(dp[j + 1][k + 1], dp[j][k])
				if ch == t2[dp[j][k]]:
					dp[j + 1][k] = max(dp[j + 1][k], dp[j][k] + 1)
		for k in range(len(t) + 1):
			if dp[len(s)][k] + k >= len(t):
				ok = True
	if ok:
		print('YES')
	else:
		print('NO')