You are given two strings $s$ and $t$, both consisting of lowercase English letters. You are going to type the string $s$ character by character, from the first character to the last one.

When typing a character, instead of pressing the button corresponding to it, you can press the "Backspace" button. It deletes the last character you have typed among those that aren't deleted yet (or does nothing if there are no characters in the current string). For example, if $s$ is "abcbd" and you press Backspace instead of typing the first and the fourth characters, you will get the string "bd" (the first press of Backspace deletes no character, and the second press deletes the character 'c'). Another example, if $s$ is "abcaa" and you press Backspace instead of the last two letters, then the resulting text is "a".

Your task is to determine whether you can obtain the string $t$, if you type the string $s$ and press "Backspace" instead of typing several (maybe zero) characters of $s$.


-----Input-----

The first line contains a single integer $q$ ($1 \le q \le 10^5$) — the number of test cases.

The first line of each test case contains the string $s$ ($1 \le |s| \le 10^5$). Each character of $s$ is a lowercase English letter.

The second line of each test case contains the string $t$ ($1 \le |t| \le 10^5$). Each character of $t$ is a lowercase English letter.

It is guaranteed that the total number of characters in the strings over all test cases does not exceed $2 \cdot 10^5$.


-----Output-----

For each test case, print "YES" if you can obtain the string $t$ by typing the string $s$ and replacing some characters with presses of "Backspace" button, 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
4
ababa
ba
ababa
bb
aaa
aaaa
aababa
ababa
Output
YES
NO
NO
YES


-----Note-----

Consider the example test from the statement.

In order to obtain "ba" from "ababa", you may press Backspace instead of typing the first and the fourth characters.

There's no way to obtain "bb" while typing "ababa".

There's no way to obtain "aaaa" while typing "aaa".

In order to obtain "ababa" while typing "aababa", you have to press Backspace instead of typing the first character, then type all the remaining characters.

Source: codeforces | Difficulty: MEDIUM
Tags: String algorithms

Dynamic programming

Amortized analysis

Greedy algorithms


Solutions:
n = int(input())
for i in range(n):
	(s, t) = (input()[::-1], input()[::-1])
	i = j = 0
	while i < len(s) and j < len(t):
		if s[i] == t[j]:
			i += 1
			j += 1
		else:
			i += 2
	print('YES' if j == len(t) else 'NO')


import math
import heapq
import string
from collections import deque
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	s = S()
	t = S()
	n = len(s)
	m = len(t)
	if m > n:
		print('NO')
		continue
	if s == t or t == '':
		print('YES')
		continue
	i = n - 1
	j = m - 1
	while i >= 0 and j >= 0:
		if s[i] != t[j]:
			i -= 2
		else:
			i -= 1
			j -= 1
	print('YES' if j < 0 else 'NO')


for i in range(int(input())):
	s = input()
	t = input()
	si = len(s) - 1
	ti = len(t) - 1
	while si >= 0 and ti >= 0:
		if s[si] == t[ti]:
			si -= 1
			ti -= 1
		else:
			si -= 1
			if si >= 0:
				si -= 1
	print('NO' if ti >= 0 else 'YES')


import sys
input = sys.stdin.readline

def solve():
	s = input().strip()
	t = input().strip()
	(n, m) = (len(s), len(t))
	(even, odd) = (-1, -1)
	for i in range(n):
		if t[0] == s[i]:
			if i % 2 == 0:
				if even == -1:
					even = i
			elif odd == -1:
				odd = i
		if even != -1 and odd != -1:
			break

	def possible(i):
		j = 0
		L = 0
		while i < n:
			to_skip = False
			if j < m and s[i] == t[j] and (L % 2 == 0):
				j += 1
				L = 0
				to_skip = True
			i += 1
			if not to_skip:
				L += 1
		return j == m and L % 2 == 0
	ans = False
	if even != -1:
		ans = ans or possible(even)
	if odd != -1:
		ans = ans or possible(odd)
	if ans:
		print('YES')
	else:
		print('NO')
	return -1
for nt in range(int(input())):
	solve()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	s = input().strip('\n')
	t = input().strip('\n')
	i = len(s) - 1
	ans = 'YES'
	j = len(t) - 1
	while j >= 0:
		if i < 0:
			ans = 'NO'
			break
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	print(ans)


def can_type(S, T):
	(S, T) = (S[::-1], T[::-1])
	(s, t) = (0, 0)
	while True:
		if s < len(S) and t < len(T) and (S[s] == T[t]):
			s += 1
			t += 1
		else:
			s += 2
		if t == len(T):
			return True
		if s > len(S):
			return False
for k in range(int(input())):
	print('YES' if can_type(input(), input()) else 'NO')


t = int(input())
for _ in range(t):
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	flag = 0
	if m > n:
		print('NO')
		continue
	pointer = (n - m) % 2
	curr = 0
	while curr < m and pointer < n:
		if s[pointer] == t[curr]:
			curr += 1
			pointer += 1
		else:
			pointer += 2
	if curr == m:
		print('YES')
	else:
		print('NO')


T = int(input())
for ia in range(T):
	s = input()
	t = input()
	n = len(s) - 1
	n1 = len(t) - 1
	while n > -1 and n1 > -1:
		if s[n] == t[n1]:
			n -= 1
			n1 -= 1
		else:
			n -= 2
	if n1 == -1:
		print('YES')
	else:
		print('NO')


zzzz = int(input())
for jj in range(zzzz):
	s = input()
	win = 1
	ans = ''
	t = input()
	if len(s) % 2 != len(t) % 2:
		s = s[1:]
	i = -1
	for k in range(len(s)):
		if s[k] == t[0] and k % 2 == 0:
			i = k
			break
	if i == -1:
		print('NO')
		continue
	for j in range(1, len(t)):
		if i >= len(s) - 1:
			win = 0
			break
		if s[i + 1] == t[j]:
			i = i + 1
			continue
		if i >= len(s) - 3:
			win = 0
			break
		i = i + 3
		while s[i] != t[j] and i < len(s) - 2:
			i += 2
		if s[i] != t[j]:
			win = 0
			break
	if win == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for k in range(t):
	s = input()
	seq = input()
	(i, j) = (len(s) - 1, len(seq) - 1)
	o = 0
	while i >= 0 and o != len(seq):
		if s[i] == seq[j]:
			i -= 1
			j -= 1
			o += 1
		if s[i] != seq[j]:
			i -= 2
	if o == len(seq):
		print('YES')
	else:
		print('NO')


def solve() -> bool:
	string = input()
	target = input()
	string_len = len(string)
	target_len = len(target)
	if string_len < target_len:
		return False
	pointer = 0
	flag = False
	for i in range((string_len - target_len) % 2, string_len):
		if flag:
			flag = False
			continue
		if pointer < target_len and string[i] == target[pointer]:
			pointer += 1
		else:
			flag = True
	return pointer == target_len
for _ in range(int(input())):
	print('YES' if solve() else 'NO')


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.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(io.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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
MOD = 1000000007

def si():
	return input()

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

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

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

def sout(v):
	print(v, end=' ')

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

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

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

def sieve(n):
	primes = []
	least_prime_divs = [0] * (n + 1)
	for i in range(2, n + 1):
		if not least_prime_divs[i]:
			least_prime_divs[i] = i
			primes.append(i)
		for p in primes:
			if i * p > n or p > least_prime_divs[i]:
				break
			least_prime_divs[i * p] = p
	return primes
t = ii()
while t:
	t -= 1
	a = si()
	b = si()
	i = len(a) - 1
	j = len(b) - 1
	while i >= 0 and j >= 0:
		if a[i] == b[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		print('YES')
	else:
		print('NO')


import sys
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(s, t):
	(n, m) = (len(s), len(t))
	while n > 0 and m > 0:
		if s[n - 1] == t[m - 1]:
			n -= 1
			m -= 1
		else:
			n -= 2
	if not m:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	s = str(input())[:-1]
	t = str(input())[:-1]
	solve(s, t)


for _ in range(int(input())):
	s = input()
	t = input()
	for c in t[::-1]:
		i = len(s) - 1
		while i >= 0:
			if s[i] != c:
				i -= 2
			else:
				s = s[:i]
				break
		else:
			print('NO')
			break
	else:
		print('YES')


import sys
import math
import random
import heapq
input = sys.stdin.readline

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

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

def bs(arr, le, ri):
	l = 0
	arr.sort()
	r = len(arr) - 1
	ans = 10000000
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= le and arr[m] <= ri:
			ans = arr[m]
			r = m - 1
		elif arr[m] < le:
			l = m + 1
		else:
			r = m - 1
	return ans

def fun(s1, s2, r1, r2, c, s, ans):
	if c >= 10:
		return
	elif s1 > s2:
		if s1 - s2 > r2:
			ans[0] = min(ans[0], c)
			return
	elif s2 > s1:
		if s2 - s1 > r1:
			ans[0] = min(ans[0], c)
			return
	if c % 2 == 0:
		r1 -= 1
		if s[c] == '1':
			s1 += 1
			fun(s1, s2, r1, r2, c + 1, s, ans)
		elif s[c] == '0':
			fun(s1, s2, r1, r2, c + 1, s, ans)
		else:
			fun(s1, s2, r1, r2, c + 1, s, ans)
			s1 += 1
			fun(s1, s2, r1, r2, c + 1, s, ans)
	else:
		r2 -= 1
		if s[c] == '1':
			s2 += 1
			fun(s1, s2, r1, r2, c + 1, s, ans)
		elif s[c] == '0':
			fun(s1, s2, r1, r2, c + 1, s, ans)
		else:
			fun(s1, s2, r1, r2, c + 1, s, ans)
			s2 += 1
			fun(s1, s2, r1, r2, c + 1, s, ans)
t = int(input())
while t > 0:
	s = input().strip()
	t1 = input().strip()
	j = len(s) - 1
	i = len(t1) - 1
	while i >= 0 and j >= 0:
		if s[j] == t1[i]:
			i -= 1
			j -= 1
		else:
			j -= 2
	if i < 0:
		print('YES')
	else:
		print('NO')
	t -= 1


import bisect
import math
import collections
import sys
import copy
from functools import reduce
import decimal
sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
graphDict = collections.defaultdict
queue = collections.deque

class Graphs:

	def __init__(self):
		self.graph = graphDict(list)

	def add_edge(self, u, v):
		self.graph[u].append(v)

	def dfs_utility(self, nodes, visited_nodes):
		visited_nodes.add(nodes)
		for neighbour in self.graph[nodes]:
			if neighbour not in visited_nodes:
				self.dfs_utility(neighbour, visited_nodes)
			else:
				return neighbour

	def dfs(self, node):
		Visited = set()
		self.dfs_utility(node, Visited)

	def bfs(self, node):
		visited = set()
		if node not in visited:
			queue.append(node)
			visited.add(node)
		while queue:
			parent = queue.popleft()
			print(parent)
			for item in self.graph[parent]:
				if item not in visited:
					queue.append(item)
					visited.add(item)

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

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

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

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	s = inp()
	t = inp()
	j = 0
	if len(t) > len(s):
		print('NO')
	else:
		ans = 'YES'
		clone = ''
		j = len(t) - 1
		i = len(s) - 1
		while i > -1:
			if s[i] == t[j]:
				clone += t[j]
				j -= 1
				i -= 1
			else:
				i -= 2
			if j < 0:
				break
		if len(clone) == len(t):
			print('YES')
		else:
			print('NO')


ans = []
for _ in range(int(input())):
	s = list(input())
	t = list(input())
	if len(s) % 2 != len(t) % 2:
		s = s[1:]
	if len(t) > len(s):
		ans.append('NO')
		continue
	i = 0
	j = 0
	while i < len(s):
		if s[i] == t[j]:
			i += 1
			j += 1
			if j == len(t):
				ans.append('YES')
				break
		else:
			i += 2
	else:
		ans.append('NO')
print('\n'.join(ans))


for _ in range(int(input())):
	s = input()
	t = input()
	(m, n) = (len(s), len(t))
	if m < n:
		print('NO')
	else:
		(i, j) = (m - 1, n - 1)
		cnt = 0
		while i >= 0 and j >= 0:
			if s[i] == t[j]:
				if cnt == 0:
					j -= 1
				else:
					cnt -= 1
			elif cnt > 0:
				cnt -= 1
			else:
				cnt += 1
			i -= 1
		if j < 0:
			print('YES')
		else:
			print('NO')


import sys

def read():
	line = sys.stdin.readline().rstrip()
	if ' ' in line:
		return line.split()
	return line.strip()

def solver():
	for (i, j) in enumerate(A):
		charIndxs[ord(j) - 97].append(i)
	for i in charIndxs[ord(B[0]) - 97]:
		if i & 1:
			if oddPos[0] == None:
				oddPos[0] = i
		elif evenPos[0] == None:
			evenPos[0] = i
	for i in range(1, len(B)):
		ascii = ord(B[i]) - 97
		lst = charIndxs[ascii]
		if oddPos[i - 1] != None:
			for j in range(oddCharIndx[ascii], len(lst)):
				if lst[j] > oddPos[i - 1] and lst[j] - oddPos[i - 1] & 1:
					oddPos[i] = lst[j]
					oddCharIndx[ascii] = j + 1
					break
		if evenPos[i - 1] != None:
			for j in range(evenCharIndx[ascii], len(lst)):
				if lst[j] > evenPos[i - 1] and lst[j] - evenPos[i - 1] & 1:
					evenPos[i] = lst[j]
					evenCharIndx[ascii] = j + 1
					break
T = int(read())
for t in range(T):
	A = read()
	B = read()
	charIndxs = [[] for _ in range(26)]
	oddPos = [None] * len(B)
	evenPos = [None] * len(B)
	oddCharIndx = [0] * 27
	evenCharIndx = [0] * 27
	solver()
	if oddPos[-1] != None and len(A) - oddPos[-1] & 1 or (evenPos[-1] != None and len(A) - evenPos[-1] & 1):
		print('YES')
	else:
		print('NO')
sys.exit()


import math
import os
import sys
from io import BytesIO, IOBase
M = 10 ** 9 + 7
import heapq
import bisect
from functools import lru_cache
from collections import *
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def valid(arr, n, c, mid):
	s = 0
	p = arr[0]
	for i in range(1, n):
		temp = arr[i] - p
		if temp >= mid:
			s += 1
			p = arr[i]
	if s >= c - 1:
		return True
	return False

def fun(n):
	s = str(n)
	ans = 0
	for i in range(len(s)):
		p = int(s[i])
		ans += math.factorial(p)
	ans = str(ans)
	res = 0
	for i in range(len(ans)):
		res += int(ans[i])
	return res

@lru_cache(None)
def main():
	t = 1
	t = inpu()
	for _ in range(t):
		a = inp()
		b = inp()
		i = len(a) - 1
		j = len(b) - 1
		while i >= 0 and j >= 0:
			if a[i] == b[j]:
				i -= 1
				j -= 1
			else:
				i -= 2
		if j == -1:
			print('YES')
		else:
			print('NO')
main()


import sys
from math import *
import builtins
import string
alphabets = list(string.ascii_lowercase)
ALPHABETS = list(string.ascii_uppercase)

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 main():
	t = get_int()
	for q in range(t):
		s = get_char_list()
		t = get_char_list()
		if len(t) > len(s):
			print('NO')
		else:
			i = len(s) - 1
			j = len(t) - 1
			while True:
				if s[i] == t[j]:
					i -= 1
					j -= 1
				else:
					i -= 2
				if j < 0:
					print('YES')
					break
				elif i < 0:
					print('NO')
					break
	pass
main()


for _ in range(int(input())):
	s = input()
	t = input()
	i = len(s) - 1
	j = len(t) - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	print('YES') if j == -1 else print('NO')
num_inp = lambda : int(input())
arr_inp = lambda : list(map(int, input().split()))
sp_inp = lambda : map(int, input().split())
str_inp = lambda : input()


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	pass
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()
from os import path
import bisect
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output1.txt', 'w')
from heapq import heappop, heappush, heapify
from math import ceil, log
from collections import defaultdict, deque
maxi = sys.maxsize
mini = -maxi
mod = 998244353
for _ in range(int(input())):
	s = input()
	t = input()
	s1 = len(s) - 1
	t1 = len(t) - 1
	i = s1
	j = t1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		print('YES')
	else:
		print('NO')


def solve():
	si = len(S) - 1
	ti = len(T) - 1
	while si >= 0 and ti >= 0:
		if S[si] != T[ti]:
			si -= 2
			continue
		ti -= 1
		si -= 1
	return 'YES' if ti == -1 else 'NO'
test_cases = int(input())
for test_case in range(test_cases):
	S = input()
	T = input()
	print(solve())


def solve():
	s = input()
	t = input()
	n = len(s) - 1
	m = len(t) - 1
	while n >= 0 and m >= 0:
		if s[n] == t[m]:
			m -= 1
			n -= 1
		else:
			n -= 2
	if m >= 0:
		print('NO')
	else:
		print('YES')

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


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)
		if m > n:
			print('no')
			continue
		i = n - 1
		j = m - 1
		bet = 0
		while j >= 0 and i >= 0:
			if s[i] == t[j] and bet % 2 == 0:
				i -= 1
				j -= 1
				bet = 0
			else:
				bet += 1
				i -= 1
		if j == -1:
			print('yes')
		else:
			print('no')
main()


q = int(input())
for _ in range(q):
	s = input()
	t = input()
	(m, n) = (len(s), len(t))
	if n > m:
		print('NO')
		continue
	q = n - 1
	k = 0
	for i in range(m - 1, -1, -1):
		if k == 1:
			k = 0
			continue
		if q >= 0 and s[i] == t[q]:
			q -= 1
		else:
			k += 1
	if q == -1:
		print('YES')
	else:
		print('NO')


def isPossible(s, t):
	(i, j) = (len(s) - 1, len(t) - 1)
	f = 0
	while j >= 0:
		while i >= 0 and s[i] != t[j]:
			i -= 2
		if i < 0:
			break
		else:
			i -= 1
		j -= 1
	if j >= 0:
		return False
	return True

def checkPossible():
	t1 = int(input())
	for k in range(t1):
		s = input()
		t = input()
		ans = isPossible(s, t)
		if ans:
			print('YES')
		else:
			print('NO')
checkPossible()


for _ in range(int(input())):
	(s, t) = (input(), input())
	(a, b, paritat) = (len(s) - 1, len(t) - 1, 0)
	while a >= 0 and b >= 0:
		if paritat == 0 and s[a] == t[b]:
			b -= 1
		else:
			paritat = (paritat + 1) % 2
		a -= 1
	print('YES' if b < 0 else 'NO')


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	s = list(input().strip())
	t = list(input().strip())
	ns = ''
	nt = ''
	n = len(s)
	m = len(t)
	tf = 1
	i = n - 1
	j = m - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
			nt += t[j]
			continue
		elif i >= 1:
			nt = nt + s[i] + s[i - 1]
			i -= 2
		else:
			tf = 0
			break
	if not tf:
		print('NO')
	elif j == -1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	if n < m:
		print('NO')
	else:
		x = m - 1
		prev = 0
		f = 0
		i = n - 1
		while i >= 0:
			if x == -1:
				f = 1
				break
			if s[i] == t[x]:
				i -= 1
				x -= 1
			else:
				i -= 2
		if f == 1 or x == -1:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	check = False
	n1 = len(s)
	n2 = len(t)
	i = n1 - 1
	j = n2 - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout, setrecursionlimit as srl
from threading import stack_size
from collections import deque, defaultdict as dd
from math import gcd, ceil
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input = stdin.readline
flush = stdout.flush
tc = 1
tc = int(input())
for _ in range(tc):
	s = input()[:-1]
	t = input()[:-1]
	if len(t) > len(s):
		print('NO')
		continue
	i = len(s) - 1
	j = len(t) - 1
	while i > -1 and j > -1:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		print('YES')
	else:
		print('NO')


import sys
number_tests = input('')
lines = []
for line in sys.stdin:
	lines.append(line)
slist = []
tlist = []
for i in range(len(lines)):
	if i % 2 == 0:
		slist.append(lines[i])
	else:
		tlist.append(lines[i])
for (s, t) in zip(slist, tlist):
	j = len(t) - 1
	i = len(s) - 1
	while j >= 0 and i >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j < 0:
		print('YES')
	else:
		print('NO')


def delete_backspace(s: str, t: str) -> bool:
	n = len(s)
	m = len(t)
	if n < m:
		return False
	i = n - m & 1
	j = 0
	while i < n:
		if j < m and t[j] == s[i]:
			j += 1
		else:
			i += 1
		i += 1
	return j == m
n_test_cases = int(input())
for _ in range(n_test_cases):
	s = input()
	t = input()
	ans = delete_backspace(s, t)
	output = 'YES' if ans else 'NO'
	print(output)


import sys, os, io
from sys import stdin
import math
from collections import defaultdict
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
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')
alphabets = list('abcdefghijklmnopqrstuvwxyz')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

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

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 sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	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 si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

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

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve():
	s = si()
	t = si()
	i = len(s) - 1
	j = len(t) - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j < 0:
		print('Yes')
	else:
		print('No')
t = 1
t = ii()
for _ in range(t):
	solve()


def main():
	for _ in range(int(input())):
		(s, t) = (list(input()), list(input()))
		while s and t:
			if s[-1] == t[-1]:
				del s[-1]
				del t[-1]
			else:
				del s[-2:]
		print(('NO', 'YES')[not t])
main()


T = int(input())
from collections import deque

def solve():
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	if n < m:
		return False
	index = m - 1
	last = n
	for i in range(n - 1, -1, -1):
		if s[i] == t[index]:
			if i == last - 1 or (last - i) % 2 != 0:
				last = i
				index -= 1
				if index == -1:
					return True
	return False
for _ in range(T):
	print('YES' if solve() else 'NO')


from sys import stdin
input = stdin.readline

def answer():
	j = 0
	for i in range(m):
		flag = False
		while j < n:
			if t[i] == s[j] and i % 2 == j % 2:
				j += 1
				flag = True
				break
			j += 1
		if flag == False:
			break
	if flag and m % 2 == n % 2:
		return 'YES'
	j = 0
	for i in range(1, m + 1):
		flag = False
		while j < n:
			if t[i - 1] == s[j] and i % 2 == j % 2:
				j += 1
				flag = True
				break
			j += 1
		if flag == False:
			break
	if flag and (m + 1) % 2 == n % 2:
		return 'YES'
	return 'NO'
for T in range(int(input())):
	s = input().strip()
	n = len(s)
	t = input().strip()
	m = len(t)
	print(answer())


from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
	s = input().rstrip()
	t = input().rstrip()
	even = -1
	odd = -1
	for i in range(len(s)):
		if s[i] == t[0]:
			if i % 2 == 0 and even == -1:
				even = i
			elif i % 2 > 0 and odd == -1:
				odd = i
	if (len(s) - len(t)) % 2 == 0:
		i = even
	else:
		i = odd
	if i == -1:
		print('NO')
		continue
	found = False
	j = 0
	while i < len(s):
		if s[i] == t[j]:
			i += 1
			j += 1
			if j >= len(t):
				found = True
				break
		else:
			i += 2
	if found:
		print('YES')
	else:
		print('NO')


import sys
import math
from bisect import bisect_right as br
from statistics import mode
from itertools import combinations as cb

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

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	a = input()
	b = input()
	i = len(a) - 1
	j = len(b) - 1
	t = ''
	while i >= 0 and j >= 0:
		if a[i] == b[j]:
			t += a[i]
			i -= 1
			j -= 1
		else:
			i -= 2
	t = t[::-1]
	if t == b:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	ss = len(s) - 1
	tt = len(t) - 1
	flag = 1
	while tt >= 0 and flag == 1:
		while ss >= 0 and s[ss] != t[tt]:
			ss = ss - 2
		if ss < 0:
			print('NO')
			flag = 0
			break
		ss = ss - 1
		tt = tt - 1
	if flag == 1:
		print('YES')


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
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')
import math
t = int(input())
for _ in range(t):
	a = input()
	b = input()
	n = len(a)
	m = len(b)
	odd = [[] for j in range(26)]
	even = [[] for j in range(26)]
	lodd = [0 for j in range(26)]
	leven = [0 for j in range(26)]
	poss = 0
	for i in range(n):
		if i % 2:
			odd[ord(a[i]) - 97].append(i)
			lodd[ord(a[i]) - 97] += 1
		else:
			even[ord(a[i]) - 97].append(i)
			leven[ord(a[i]) - 97] += 1
	b = b[::-1]
	if n % 2 != 0:
		if leven[ord(b[0]) - 97] > 0:
			last = 0
			lastpos = even[ord(b[0]) - 97][-1]
			j = 1
			even[ord(b[0]) - 97].pop()
			leven[ord(b[0]) - 97] += -1
			f = 1
			while j < m:
				if last % 2 == 0:
					while lodd[ord(b[j]) - 97] >= 0:
						if lodd[ord(b[j]) - 97] == 0:
							f = 0
							break
						if odd[ord(b[j]) - 97][-1] < lastpos:
							lastpos = odd[ord(b[j]) - 97][-1]
							last = 1
							odd[ord(b[j]) - 97].pop()
							lodd[ord(b[j]) - 97] += -1
							break
						else:
							odd[ord(b[j]) - 97].pop()
							lodd[ord(b[j]) - 97] += -1
							if lodd[ord(b[j]) - 97] == 0:
								f = 0
								break
						if f == 0:
							break
				else:
					while leven[ord(b[j]) - 97] >= 0:
						if leven[ord(b[j]) - 97] == 0:
							f = 0
							break
						if even[ord(b[j]) - 97][-1] < lastpos:
							lastpos = even[ord(b[j]) - 97][-1]
							last = 0
							even[ord(b[j]) - 97].pop()
							leven[ord(b[j]) - 97] += -1
							break
						else:
							even[ord(b[j]) - 97].pop()
							leven[ord(b[j]) - 97] += -1
							if leven[ord(b[j]) - 97] == 0:
								f = 0
								break
						if f == 0:
							break
				if f == 0:
					break
				j += 1
			if f:
				poss = 1
	elif lodd[ord(b[0]) - 97] > 0:
		last = 1
		lastpos = odd[ord(b[0]) - 97][-1]
		j = 1
		odd[ord(b[0]) - 97].pop()
		lodd[ord(b[0]) - 97] += -1
		f = 1
		while j < m:
			if last % 2 == 0:
				while lodd[ord(b[j]) - 97] >= 0:
					if lodd[ord(b[j]) - 97] == 0:
						f = 0
						break
					if odd[ord(b[j]) - 97][-1] < lastpos:
						lastpos = odd[ord(b[j]) - 97][-1]
						last = 1
						odd[ord(b[j]) - 97].pop()
						lodd[ord(b[j]) - 97] += -1
						break
					else:
						odd[ord(b[j]) - 97].pop()
						lodd[ord(b[j]) - 97] += -1
						if lodd[ord(b[j]) - 97] == 0:
							f = 0
							break
					if f == 0:
						break
			else:
				while leven[ord(b[j]) - 97] >= 0:
					if leven[ord(b[j]) - 97] == 0:
						f = 0
						break
					if even[ord(b[j]) - 97][-1] < lastpos:
						lastpos = even[ord(b[j]) - 97][-1]
						last = 0
						even[ord(b[j]) - 97].pop()
						leven[ord(b[j]) - 97] += -1
						break
					else:
						even[ord(b[j]) - 97].pop()
						leven[ord(b[j]) - 97] += -1
						if leven[ord(b[j]) - 97] == 0:
							f = 0
							break
					if f == 0:
						break
			if f == 0:
				break
			j += 1
		if f:
			poss = 1
	if poss:
		print('YES')
	else:
		print('NO')


def get_solution(s, t):
	n = len(s)
	n_2 = len(t)
	if n_2 > n:
		print('NO')
		return
	i = n - 1
	j = n_2 - 1
	while j >= 0 and i >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		print('YES')
		return
	print('NO')
for _ in range(int(input())):
	get_solution(input(), input())


N = int(input())
for _ in range(N):
	(s, t) = (list(input()), list(input()))
	while s and t:
		if s[-1] == t[-1]:
			s.pop()
			t.pop()
		else:
			s.pop()
			if s:
				s.pop()
	print('NO' if t else 'YES')


for _ in range(int(input())):
	(s, t) = (input(), input())
	(ps, pt) = (len(s) - 1, len(t) - 1)
	ans = ''
	while ps >= 0 and len(ans) != len(t):
		if s[ps] == t[pt]:
			ans += t[pt]
			ps -= 1
			pt -= 1
		else:
			ps -= 2
	if len(ans) == len(t):
		print('YES')
	else:
		print('NO')


def solve(s, t):
	mod_done = []
	for (i, letter) in enumerate(s):
		pointer = 0
		if letter == t[0]:
			if i % 2 in mod_done:
				continue
			pointer = 1
			current = i + 1
			last = i
			if pointer == len(t):
				if (len(s) - i) % 2 == 1:
					return 'YES'
				else:
					continue
			for j in range(current, len(s)):
				if j % 2 != last % 2:
					if s[j] == t[pointer]:
						pointer += 1
						last = j
				if pointer == len(t):
					if (len(s) - j) % 2 == 1:
						return 'YES'
					else:
						break
			mod_done.append(i % 2)
	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)


t = int(input())
for _ in range(t):
	s = str(input())
	t = str(input())
	lt = len(t)
	ls = len(s)
	if lt > ls or ls + 1 == lt:
		print('No')
		continue
	j = len(t) - 1
	i = len(s) - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		print('Yes')
	else:
		print('No')


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)
	c = [[] for i in range(26)]
	for i in range(ns):
		c[ord(s[i]) - 97].append(i)
	ind = ns
	st = []
	ideme = False
	for i in reversed(range(nr)):
		ideme = False
		while c[ord(r[i]) - 97]:
			pot = c[ord(r[i]) - 97].pop()
			if pot < ind and (ns - pot) % 2 == (nr - i) % 2:
				ind = pot
				st.append(pot)
				ideme = True
				break
		if not ideme:
			break
	if ideme:
		print('YES')
	else:
		print('NO')


for testis in range(int(input())):
	s = input()
	t = input()
	(n, m) = (len(s), len(t))
	if m > n:
		print('NO')
	else:
		(p, q) = (n - 1, m - 1)
		while q >= 0:
			if s[p] == t[q]:
				p -= 1
				q -= 1
			else:
				p -= 2
			if p < 0:
				break
		if q >= 0:
			print('NO')
		else:
			print('YES')


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
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')

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

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

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

def primeFactorsCount(n):
	cnt = 0
	while n % 2 == 0:
		cnt += 1
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt += 1
			n = n // i
	if n > 2:
		cnt += 1
	return cnt

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s

def chkOdd(evodd):
	par = evodd
	cpos = -1
	for i in range(0, len(t)):
		val = ord(t[i]) - 97
		l = pos[par][val]
		if len(l) > 0 and l[-1] >= cpos:
			ind = bisect.bisect(l, cpos)
			cpos = l[ind]
			par = 1 - par
		else:
			return False
	if (len(s) - 1 - cpos) % 2 == 0:
		return True
	return False
for xyz in range(0, int(input())):
	s = input()
	t = input()
	if len(t) > len(s):
		print('NO')
	else:
		pos = [[[] for i in range(0, 26)] for j in range(0, 2)]
		for i in range(0, len(s)):
			val = ord(s[i]) - 97
			pos[i % 2][val].append(i)
		if chkOdd(0) or chkOdd(1):
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	s1 = input()
	s2 = input()
	tr = 0
	for i in range(len(s1) - 1, -1, -1):
		if s1[i] == s2[-1] and (len(s1) - i - tr) % 2 == 1:
			tr += 1
			s2 = s2[:-1]
			if len(s2) == 0:
				break
	if len(s2) == 0:
		print('YES')
	else:
		print('NO')


from sys import stdin as sin

def aint():
	return int(input())

def amap():
	return map(int, sin.readline().split())

def alist():
	return list(map(int, sin.readline().split()))

def astr():
	return input()
for _ in range(aint()):
	s = input()
	t = input()
	if len(s) >= len(t):
		j = len(s) - 1
		c = 0
		i = len(t) - 1
		while i >= 0:
			if j >= 0:
				if s[j] != t[i]:
					j -= 2
					i += 1
				else:
					c += 1
					j -= 1
			else:
				break
			i -= 1
		if j >= -1 and c == len(t):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from itertools import product, permutations, combinations, accumulate, compress
import os, sys
input = lambda : sys.stdin.buffer.readline().rstrip(b'\r\n')

def dbp(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)
a_str = lambda : input().decode('ascii')
get_int_list = lambda : [int(x) for x in input().split()]
join_str = lambda l, ch=' ': ch.join((str(x) for x in l))

def slow_solve(s, t):
	for p in product((False, True), repeat=len(s)):
		ans = []
		for (idx, pi) in enumerate(p):
			if pi:
				ans.append(s[idx])
			elif ans:
				ans.pop()
		if ''.join(ans) == t:
			return 'YES'
	return 'NO'

def WA1(s, t):
	if len(t) > len(s):
		dbp('length t > s early out')
		return 'NO'
	if len(t) == len(s):
		dbp('same length early out')
		return 'YES' if t == s else 'NO'
	if t == s[-len(t):]:
		dbp('suffix match early out')
		return 'YES'
	sidx = tidx = 0
	ans = []
	while sidx < len(s):
		if tidx >= len(t) or s[sidx] != t[tidx]:
			if ans:
				ans.pop()
				tidx -= 1
		else:
			ans.append(s[sidx])
			tidx += 1
		sidx += 1
	final = ''.join(ans)
	return 'YES' if final == t else 'NO'

def WA2(s, t):
	ans = []
	sidx = len(s) - 1
	for tidx in range(len(t) - 1, -1, -1):
		while sidx >= 0 and t[tidx] != s[sidx]:
			sidx -= 2
		if sidx < 0:
			return 'NO'
		ans.append(s[sidx])
		sidx -= 1
		if len(ans) == len(t):
			if ''.join(ans[::-1]) == t:
				return 'YES'
	final = ''.join(ans[::-1])
	return 'YES' if final == t else 'NO'

def do_thing():
	s = a_str()
	t = a_str()
	dbp('case:', s, t)
	wa2 = WA2(s, t)
	return wa2

def multicase():
	maxcc = int(input().strip())
	for cc in range(maxcc):
		print(do_thing())
multicase()


import sys

def solver(source, target):
	if len(target) > len(source):
		return False
	elif len(target) == len(source):
		return source == target
	elif len(target) == 0:
		return True
	else:
		c_source = len(source) - 1
		for i_target in range(len(target) - 1, -1, -1):
			found = False
			g = target[i_target]
			for i_source in range(c_source, -1, -2):
				if source[i_source] == g:
					c_source = i_source - 1
					found = True
					break
			if not found:
				return False
		return True
stdin_iter = iter(sys.stdin)
num_tests = int(next(stdin_iter))
for _ in range(num_tests):
	source = next(stdin_iter)
	target = next(stdin_iter)
	print('YES' if solver(source, target) else 'NO')


def solve(s, t):
	n1 = len(s)
	n2 = len(t)
	if n1 < n2:
		return 'NO'
	s.reverse()
	t.reverse()
	j = 0
	k = 0
	diff = 0
	while k < n1 and j < n2:
		if s[k] == t[j] and diff % 2 == 0:
			j += 1
			diff = 0
		else:
			diff += 1
		k += 1
	if j == n2:
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	s = list(input())
	t = list(input())
	print(solve(s, t))


n_examples = input()
for x in range(int(n_examples)):
	s = input()
	t = input()
	i = len(s) - 1
	j = len(t) - 1
	while i > -1:
		if j != -1 and s[i] == t[j]:
			j -= 1
		else:
			i -= 1
		i -= 1
	print('YES') if j == -1 else print('NO')


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
ABCD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
months = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
MOD = 1000000007
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

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())):
	s1 = input()
	s2 = input()
	s1 = s1[::-1]
	s2 = list(s2[::-1])
	s3 = []
	i = j = 0
	n = len(s1)
	m = len(s2)
	if m > n:
		print('NO')
		continue
	ans = 'NO'
	while i < n:
		if j == m:
			break
		if s1[i] == s2[j]:
			s3.append(s2[j])
			i += 1
			j += 1
		else:
			i += 2
	if s3 == s2:
		print('YES')
	else:
		print('NO')


import typing

def solve(s: str, t: str) -> typing.NoReturn:
	i = j = 0
	(n, m) = (len(s), len(t))
	while 1:
		(ri, rj) = (n - i, m - j)
		if ri < rj:
			print('NO')
			return
		if ri - rj & 1:
			i += 1
			continue
		if j == m:
			print('YES')
			return
		if s[i] == t[j]:
			j += 1
		i += 1

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


from sys import stdout
out = lambda x, end='\n': stdout.write(str(x) + end)
ip = [*open(0)]
for i in range(0, 2 * int(ip[0]), 2):
	(s, t) = (ip[i + 1][:-1], ip[i + 2][:-1])
	if t == s:
		out('YES')
	elif len(t) >= len(s):
		out('NO')
	else:
		i = len(s) - 1
		j = len(t) - 1
		while i >= 0 and j >= 0:
			if s[i] == t[j]:
				i -= 1
				j -= 1
			else:
				i -= 2
		if j == -1:
			out('YES')
		else:
			out('NO')


def f(s, t):
	temp = list(t)
	if len(s) < len(t):
		return 'NO'
	i = len(s) - 1
	while i >= 0:
		if s[i] == temp[-1]:
			temp.pop(-1)
			if len(temp) == 0:
				return 'YES'
		else:
			i -= 1
		i -= 1
	return 'NO'
for i in range(int(input())):
	s = input()
	t = input()
	print(f(s, t))


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 len(t) > len(s):
		return False
	elif len(t) == len(s):
		if s == t:
			return True
		else:
			return False
	st = {0: -1, 1: -1}
	for i in range(len(s)):
		if s[i] == t[0]:
			if st[i % 2] == -1:
				st[i % 2] = i
	if st[0] == -1:
		fi = False
	else:
		fi = True
		start = st[0]
		last = start
		j = 1
		for i in range(start + 1, len(s)):
			if j == len(t):
				if (len(s) - i) % 2 == 1:
					fi = False
				break
			if s[i] == t[j]:
				lastRem = last % 2
				currRem = i % 2
				if lastRem == currRem:
					pass
				else:
					last = i
					j += 1
		if j == len(t) and fi:
			fi = True
		else:
			fi = False
	if st[1] == -1:
		se = False
	else:
		se = True
		start = st[1]
		last = start
		j = 1
		for i in range(start + 1, len(s)):
			if j == len(t):
				if (len(s) - i) % 2 == 1:
					se = False
				break
			if s[i] == t[j]:
				lastRem = last % 2
				currRem = i % 2
				if lastRem == currRem:
					pass
				else:
					last = i
					j += 1
		if j == len(t) and se:
			se = True
		else:
			se = False
	return fi or se
for _ in range(stdint()):
	if solve():
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	a = list(input())
	b = list(input())
	ind = dict()
	n = len(a)
	for i in range(len(a)):
		if a[i] not in ind:
			ind[a[i]] = [i]
		else:
			ind[a[i]].append(i)
	j = 0
	last = 0
	done = 0
	for i in range(len(b)):
		cau = j
		if i == 0:
			while j < n:
				if a[j] == b[i] and j % 2 == 0:
					last = j
					j += 1
					done += 1
					break
				j += 1
		else:
			while j < n:
				if a[j] == b[i] and (j - last) % 2 == 1:
					last = j
					j += 1
					done += 1
					break
				j += 1
		if cau == j or j == n:
			break
		if done == len(b):
			break
	if done == len(b) and (j - len(a)) % 2 == 0:
		print('YES')
		continue
	j = 0
	last = 0
	done = 0
	for i in range(len(b)):
		cau = j
		if i == 0:
			while j < n:
				if a[j] == b[i] and j % 2 == 1:
					last = j
					j += 1
					done += 1
					break
				j += 1
		else:
			while j < n:
				if a[j] == b[i] and (j - last) % 2 == 1:
					last = j
					j += 1
					done += 1
					break
				j += 1
		if cau == j or j == n:
			break
		if done == len(b):
			break
	if done == len(b) and (j - len(a)) % 2 == 0:
		print('YES')
		continue
	print('NO')


for _ in range(int(input())):
	s = list(input())
	t = input()
	(n, m) = (len(s) - 1, len(t) - 1)
	while n >= 0 and m >= 0:
		if s[n] == t[m]:
			n -= 1
			m -= 1
		else:
			n -= 2
	print('YES') if m < 0 else print('NO')


import sys
import os.path
from collections import *
import math
import bisect
import heapq as hq
from fractions import Fraction
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
t = int(input())
while t:
	t -= 1
	s = input()
	s1 = input()
	if len(s) < len(s1):
		print('NO')
		continue
	if s == s1:
		print('YES')
		continue
	s = s[::-1]
	s1 = s1[::-1]
	i = 0
	res = False
	j = 0
	while i < len(s):
		if s[i] == s1[j]:
			j += 1
		else:
			i += 1
		i += 1
		if j == len(s1):
			res = True
			break
	if res:
		print('YES')
	else:
		print('NO')


def check(s, t):
	i = len(s) - 1
	j = len(t) - 1
	if i < j:
		return 'NO'
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
		if j == -1:
			return 'YES'
	return 'NO'
test_cases = int(input())
array = []
while test_cases != 0:
	s = input()
	t = input()
	test_cases -= 1
	array.append(check(s, t))
for i in array:
	print(i)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	s = input()
	t = input()
	(n, m) = (len(s), len(t))
	(i, j) = (0, 0)
	prev = -1
	n -= 1
	m -= 1
	while i < n and j < m:
		if s[i] == t[j]:
			if prev == -1:
				prev = i
				i += 1
				j += 1
			elif (i - prev) % 2:
				i += 1
				j += 1
				prev = i - 1
			else:
				i += 1
		else:
			i += 1
	last = n
	for i in range(n, -1, -1):
		if s[i] == t[-1] and (n + 1 - i) % 2:
			last = i
			break
	if j == m and last > prev and (s[last] == t[-1]) and (prev == -1 or (last - prev) % 2) and (n + 1 - last) % 2:
		print('Yes')
		continue
	if t[0] not in s:
		print('No')
		continue
	start = 0
	ind = s.index(t[0]) % 2
	for i in range(n + 1):
		if s[i] == t[0] and i % 2 != ind:
			start = i
			break
	(i, j) = (start, 0)
	prev = -1
	while i < n and j < m:
		if s[i] == t[j]:
			if prev == -1:
				prev = i
				i += 1
				j += 1
			elif (i - prev) % 2:
				i += 1
				j += 1
				prev = i - 1
			else:
				i += 1
		else:
			i += 1
	if j == m and last > prev and (s[last] == t[-1]) and (prev == -1 or (last - prev) % 2) and (n + 1 - last) % 2:
		print('Yes')
	else:
		print('No')


from math import floor, gcd, sqrt, ceil

def main():
	for _ in range(int(input())):
		s = list(input())
		t = list(input())
		try:
			while s and t:
				if s[-1] == t[-1]:
					s.pop()
					t.pop()
				else:
					s.pop()
					s.pop()
			if t:
				print('NO')
			else:
				print('YES')
		except:
			print('NO')
main()


T = int(input())
for t in range(T):
	s = input()
	t = input()
	ss = s[::-1]
	tt = t[::-1]
	j = 0
	for i in range(len(tt)):
		while j < len(ss) and ss[j] != tt[i]:
			j += 2
		j += 1
	if j > len(ss):
		print('NO')
	else:
		print('YES')


def naiveSolve():
	return

def main():
	t = int(input())
	allans = []
	for _ in range(t):
		s = input()
		t = input()
		n = len(s)
		m = len(t)
		i = n - 1
		ans = 'NO'
		j = m - 1
		while j >= 0:
			while i >= 0 and s[i] != t[j]:
				i -= 2
			if i < 0:
				break
			i -= 1
			j -= 1
		if j == -1:
			ans = 'YES'
		allans.append(ans)
	multiLineArrayPrint(allans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(l, r):
	print('? {} {}'.format(l, r))
	sys.stdout.flush()
	return int(input())

def answerInteractive(x):
	print('! {}'.format(x))
	sys.stdout.flush()
inf = float('inf')
MOD = 998244353
from math import gcd, floor, ceil
for _abc in range(1):
	main()


def canSproduceT(s, t):
	n = len(s)
	m = len(t)
	if m == 0:
		return 'YES'
	if n < m:
		return 'NO'
	i = n - 1
	j = m - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		return 'YES'
	return 'NO'
tests = int(input())
results = []
while tests:
	s = input()
	t = input()
	print(canSproduceT(s, t))
	tests -= 1


import sys
input = sys.stdin.buffer.readline

def solve():
	si = len(S) - 1
	ti = len(T) - 1
	while si >= 0 and ti >= 0:
		if S[si] != T[ti]:
			si -= 2
			continue
		ti -= 1
		si -= 1
	return 'YES' if ti == -1 else 'NO'
test_cases = int(input())
for test_case in range(test_cases):
	S = input()
	T = input()
	print(solve())


for _ in range(int(input())):
	a = list(input())
	b = list(input())
	while a and b:
		if a[-1] == b[-1]:
			a.pop()
			b.pop()
		else:
			a.pop()
			if a:
				a.pop()
	print('NO' if b else 'YES')


import time
from queue import Queue
from itertools import accumulate, count
from io import BytesIO, IOBase
from itertools import combinations
import threading
from collections import deque
from functools import reduce, cmp_to_key
import sys
from math import sqrt
import heapq
import random
import math
from collections import defaultdict
from collections import Counter
import io
import os
import bisect
from fractions import Fraction

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

def iinput():
	return int(input())

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

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

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

def swap(arr, a, b):
	(arr[a], arr[b]) = (arr[b], arr[a])
for _ in range(iinput()):
	a = input()
	b = input()
	if len(a) < len(b):
		print('NO')
		continue
	flag = True
	pastFound = len(a)
	currentInB = len(b) - 1
	for i in range(len(a) - 1, -1, -1):
		if currentInB == -1:
			break
		if (pastFound - i - 1) % 2 == 0:
			if a[i] == b[currentInB]:
				pastFound = i
				currentInB -= 1
	if currentInB != -1:
		flag = False
	print(['NO', 'YES'][flag])


q = int(input())

def solve():
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	i = n - 1
	j = m - 1
	delete = 0
	while i >= 0 and j >= 0:
		if s[i] == t[j] and (not delete):
			j -= 1
		else:
			delete ^= 1
		i -= 1
	if j < 0:
		print('YES')
	else:
		print('NO')
for _ in range(q):
	solve()


def sex(s, t):
	now = len(s) - 1
	i = len(t) - 1
	while now >= 0:
		if s[now] == t[i]:
			now -= 1
			i -= 1
		else:
			now -= 2
		if i == -1:
			return 'YES'
	return 'NO'
q = int(input())
for _ in range(q):
	s = input()
	t = input()
	print(sex(s, t))


def solution(s, t):
	s = list(s)
	t = list(t)
	while len(s) >= len(t):
		if not t:
			return 'YES'
		if s[-1] == t[-1]:
			s.pop()
			t.pop()
		else:
			s.pop()
			if s:
				s.pop()
	return 'NO'

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


t = int(input())
results = []
for i in range(t):
	text = input()[::-1]
	word = input()[::-1]
	i_text = 0
	i_word = 0
	while i_text < len(text) and i_word < len(word):
		if word[i_word] == text[i_text]:
			i_text += 1
			i_word += 1
		else:
			i_text += 2
	results.append(i_word == len(word))
for i in range(t):
	if results[i]:
		print('YES')
	else:
		print('NO')


def run(*tasks):
	value = None

	def tick():
		nonlocal value
		task = tasks[-1]
		try:
			subtask = task.send(value)
			tasks.append(subtask)
			value = None
		except TypeError as error:
			if error.args == ("can't send non-None value to a just-started generator",):
				subtask = task.send(None)
				tasks.append(subtask)
			else:
				raise error
		except StopIteration as stop:
			value = stop.value
			tasks.pop()
	tasks = list(tasks)
	while len(tasks) != 0:
		tick()
	return value

def shortest_walk(keys, target):
	if len(target) == 0:
		return keys
	(first, rest) = (target[0], target[1:])
	keys1 = (yield shortest_walk(keys, rest))
	if keys1 == None:
		return None
	while keys1 != '':
		if keys1[-1] == first:
			return keys1[:-1]
		keys1 = keys1[:-2]
	else:
		return None

def shortest_walk_iter(keys, target):
	for first in target[::-1]:
		while keys != '':
			if keys[-1] == first:
				keys = keys[:-1]
				break
			keys = keys[:-2]
		else:
			return None
	return keys
ntests = int(input())
for t in range(ntests):
	keys = input()
	target = input()
	possible = shortest_walk_iter(keys, target) != None
	print('YES' if possible else 'NO')


import sys

def checkBack(s, t):
	ptr1 = 1
	ptr2 = 1
	if len(t) > len(s):
		return False
	while ptr2 <= len(t) and ptr1 <= len(s):
		if s[-ptr1] == t[-ptr2]:
			(ptr1, ptr2) = (ptr1 + 1, ptr2 + 1)
			continue
		elif ptr1 == len(s):
			return False
		elif ptr1 == len(s) - 1:
			return False
		else:
			ptr1 = ptr1 + 2
	return ptr2 == len(t) + 1
data = sys.stdin.read().split()
cases = data[0]
ss = data[1::2]
ts = data[2::2]
for i in range(int(cases)):
	if checkBack(ss[i], ts[i]):
		print('YES')
	else:
		print('NO')


def solve_one():
	s = input().strip()
	t = input().strip()
	si = len(s) - 1
	ti = len(t) - 1
	while si >= 0 and ti >= 0:
		if t[ti] == s[si]:
			si -= 1
			ti -= 1
		else:
			si -= 2
	if ti < 0:
		print('YES')
	else:
		print('NO')
n = int(input())
for _ in range(n):
	solve_one()


for _ in range(int(input())):
	s = input()
	t = input()
	j = len(t) - 1
	i = len(s) - 1
	c = 0
	while i >= 0 and j >= 0:
		if c % 2 == 0 and s[i] == t[j]:
			i -= 1
			j -= 1
			c = 0
			continue
		i -= 1
		c += 1
	if j < 0:
		print('YES')
	else:
		print('NO')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

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

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 999999999999999999999999
alphabets = 'abcdefghijklmnopqrstuvwxyz'

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))

class SegTree:

	def __init__(self, n):
		self.N = 1 << n.bit_length()
		self.tree = [0] * (self.N << 1)

	def update(self, i, j, v):
		i += self.N
		j += self.N
		while i <= j:
			if i % 2 == 1:
				self.tree[i] += v
			if j % 2 == 0:
				self.tree[j] += v
			(i, j) = (i + 1 >> 1, j - 1 >> 1)

	def query(self, i):
		v = 0
		i += self.N
		while i > 0:
			v += self.tree[i]
			i >>= 1
		return v

def SieveOfEratosthenes(limit):
	isPrime = [True] * (limit + 1)
	isPrime[0] = isPrime[1] = False
	primes = []
	for i in range(2, limit + 1):
		if not isPrime[i]:
			continue
		primes += [i]
		for j in range(i * i, limit + 1, i):
			isPrime[j] = False
	return primes

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = ri()
	for _ in range(tc):
		s = list(rs()) + ['.']
		t = list(rs()) + ['.']
		posinds = []
		po = []
		pe = []
		for i in range(len(s)):
			if s[i] == t[0]:
				if i % 2:
					po.append(i)
				else:
					pe.append(i)
		if pe:
			posinds.append(pe[0])
		if po:
			posinds.append(po[0])
		milgaya = 0
		for inds in posinds:
			indt = 1
			par = inds % 2
			inds += 1
			while indt < len(t) and inds < len(s):
				while indt < len(t) and inds < len(s):
					if s[inds] == t[indt] and inds % 2 == 1 - par:
						par = 1 - par
						indt += 1
						inds += 1
						break
					else:
						inds += 1
			if indt == len(t):
				ws('YES')
				milgaya = 1
				break
		if milgaya == 0:
			ws('NO')
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


cant_tests = int(input())
s = []
t = []
for i in range(cant_tests):
	s.append(input())
	t.append(input())
for j in range(cant_tests):
	str = s[j]
	t1 = [0, -1]
	t2 = [0, -2]
	for i in range(len(str)):
		if t[j][t1[0]] == str[i] and i % 2 != t1[1] % 2:
			t1[0] += 1
			t1[1] = i
		if t[j][t2[0]] == str[i] and i % 2 != t2[1] % 2:
			t2[0] += 1
			t2[1] = i
		if t1[0] == len(t[j]):
			if (len(str) - t1[1] - 1) % 2 == 0:
				print('YES')
				break
			else:
				t1[0] -= 1
				t1[1] -= 1
		if t2[0] == len(t[j]):
			if (len(str) - t2[1] - 1) % 2 == 0:
				print('YES')
				break
			else:
				t2[0] -= 1
				t2[1] -= 1
		if i == len(str) - 1:
			print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	s = input()[:-1]
	t = input()[:-1]
	if len(s) % 2 != len(t) % 2:
		s = s[1:]
	idx = 0
	i = 0
	while i < len(s):
		if idx < len(t) and s[i] == t[idx]:
			i += 1
			idx += 1
		else:
			i += 2
	if idx == len(t):
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
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()
for _ in range(int(input())):
	s = input()
	t = input()
	(m, n) = (len(s), len(t))
	(i, j) = (m - 1, n - 1)
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j < 0:
		print('YES')
	else:
		print('NO')


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

	def solve(s, t):
		ind = 0
		for ch in t:
			while ind < len(s) and s[ind] != ch:
				ind += 2
			if ind >= len(s):
				return 'NO'
			ind += 1
		return 'YES'
	print(solve(s[::-1], t[::-1]))


for _ in range(int(input())):
	s = input()
	t = input()
	s = s[::-1]
	t = t[::-1]
	k = 0
	last = -1
	ans = False
	for i in range(len(s)):
		if s[i] == t[k] and (i - last + 1) % 2 == 0:
			k += 1
			last = i
		if k == len(t):
			ans = True
			break
	print('YES' if ans else 'NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	s = input()[:-1]
	t = input()[:-1]
	(n, m) = (len(s), len(t))
	(i, j) = (n - 1, m - 1)
	cnt = 0
	while i >= 0 and j >= 0:
		while cnt:
			i -= 1
			cnt -= 1
		if i < 0:
			break
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			cnt += 1
			i -= 1
	print('YES' if j < 0 else 'NO')


import sys
import io, os
input = sys.stdin.readline
Q = int(input())
for _ in range(Q):
	s = str(input().rstrip())
	t = str(input().rstrip())
	n = len(s)
	m = len(t)
	cur = m - 1
	skip = False
	flag = False
	for i in reversed(range(n)):
		if skip:
			skip = False
			continue
		if s[i] == t[cur]:
			cur -= 1
			if cur < 0:
				flag = True
				break
		else:
			skip = True
	if flag:
		print('YES')
	else:
		print('NO')


for k in range(int(input())):
	x = input()
	y = input()
	i = len(x) - 1
	j = len(y) - 1
	while i >= 0 and j >= 0:
		if x[i] == y[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	print(['NO', 'YES'][j == -1])


t = int(input())
for _ in range(t):
	s = input()[::-1]
	t = input()[::-1]
	if len(t) > len(s):
		print('no')
		continue
	fin = ''
	z = 0
	for x in t:
		for y in range(z, len(s), 2):
			ch = s[y]
			if ch == x:
				z = y + 1
				fin += ch
				break
	if fin == t:
		print('yes')
	else:
		print('no')


def solve():
	s = input()
	t = input()
	cur = len(s) & 1 ^ len(t) & 1
	for (i, a) in enumerate(t):
		while True:
			if cur >= len(s):
				return 'NO'
			if s[cur] == a:
				break
			cur += 2
		cur += 1
	return 'YES'
t = int(input())
for __ in range(t):
	print(solve())


from sys import stdin
q = int(stdin.readline())
for loop in range(q):
	s = list(stdin.readline()[:-1])
	t = list(stdin.readline()[:-1])
	while len(s) > 0 and len(t) > 0:
		if s[-1] == t[-1]:
			del s[-1]
			del t[-1]
		else:
			del s[-1]
			if len(s) > 0:
				del s[-1]
	if len(t) == 0:
		print('YES')
	else:
		print('NO')


from math import *
from collections import *
from functools import *
from bisect import *
from itertools import *
from heapq import *
from statistics import *
inf = float('inf')
ninf = -float('inf')
ip = input
alphal = 'abcdefghijklmnopqrstuvwxyz'
alphau = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def ipl():
	return list(map(int, ip().split()))

def ipn():
	return int(ip())

def ipf():
	return float(ip())

def solve():
	(s, t) = (ip(), ip())
	(n, m) = (len(s) - 1, len(t) - 1)
	(i, j) = (n, m)
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	print('YES' if j < 0 else 'NO')
t = ipn()
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline

def solve():
	s = input().strip()
	t = input().strip()
	i = len(t) - 1
	j = len(s) - 1
	while i >= 0:
		while j >= 0 and s[j] != t[i]:
			j -= 2
		if j < 0:
			print('NO')
			return
		j -= 1
		i -= 1
	print('YES')
for i in range(int(input())):
	solve()


import time
import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import bisect_left, bisect_right
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string, heapq as h
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')

def getInt():
	return int(input())

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

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

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def getBin():
	return list(map(int, list(input())))

def isInt(s):
	return '0' <= s[0] <= '9'

def ceil_(a, b):
	return (a + b - 1) // b
MOD = 10 ** 9 + 7

def solve():
	(S, T) = (listStr(), listStr())
	i = j = par = 0
	(N, M) = (len(S), len(T))
	while i < N:
		if i % 2 == par and S[i] == T[j]:
			i += 1
			j += 1
			par ^= 1
		else:
			i += 1
		if j == M and i % 2 == N % 2:
			return 'YES'
		elif j == M:
			break
	i = j = 0
	par = 1
	while i < N:
		if i % 2 == par and S[i] == T[j]:
			i += 1
			j += 1
			par ^= 1
		else:
			i += 1
		if j == M and i % 2 == N % 2:
			return 'YES'
		elif j == M:
			break
	return 'NO'
for _ in range(getInt()):
	print(solve())


import sys
import math
import random
from queue import PriorityQueue as PQ
from bisect import bisect_left as BSL
from bisect import bisect_right as BSR
from collections import OrderedDict as OD
from collections import Counter
from itertools import permutations
mod = 1000000007
sys.setrecursionlimit(1000000)
try:
	sys.stdin = open('actext.txt', 'r')
	OPENFILE = 1
except:
	pass

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

def palindrome(s):
	mid = len(s) // 2
	for i in range(mid):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True

def check(i, n):
	if 0 <= i < n:
		return True
	else:
		return False
t = int(input())
for tt in range(t):
	a = input()
	b = input()
	ans = 0
	i = len(a) - 1
	j = len(b) - 1
	while i >= 0 and j >= 0:
		if a[i] == b[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
		if j == -1:
			ans = 1
	if ans == 1:
		print('YES')
	else:
		print('NO')


def solve(s, t):
	dels = len(s) - len(t)
	si = 0
	ti = 0
	while si < len(s) and ti < len(t):
		if t[ti] == s[si]:
			ti += 1
			si += 1
		else:
			si += 2
	if ti == len(t):
		return True
	return False
for _ in range(int(input())):
	s = input()
	s = s[::-1]
	t = input()
	t = t[::-1]
	if solve(s, t):
		print('YES')
	else:
		print('NO')


ali = 0
from collections import defaultdict, Counter, deque
ali = 0
ali = 0
ali = 0
from math import sqrt, log10, log, floor, factorial
ali = 0
ali = 0
ali = 0
from bisect import bisect_left, bisect_right
ali = 0
ali = 0
ali = 0
from itertools import permutations, combinations
ali = 0
ali = 0
ali = 0
import sys, io, os
ali = 0
ali = 0
ali = 0
input = sys.stdin.readline
ali = 0
ali = 0
ali = 0
ali = 0
ali = 0
ali = 0
ali = 0
ali = 0
ali = 0
inf = float('inf')
ali = 0
ali = 0
ali = 0
mod = 10 ** 9 + 7
ali = 0
ali = 0

def get_list():
	return [int(i) for i in input().split()]
	ali = 0
ali = 0

def yn(a):
	print('YES' if a else 'NO')
	ali = 0
ali = 0
ali = 0
ceil = lambda a, b: (a + b - 1) // b
ali = 0
ali = 0
ali = 0
t = int(input())
ali = 0
ali = 0

def search(s, t, a, b, odd):
	for i in range(n):
		ali = 0
		if i % 2 == odd and b < len(t) and (s[i] == t[b]):
			ali = 0
			odd ^= 1
			ali = 0
			ali = 0
			ali = 0
			b += 1
			ali = 0
			ali = 0
	ali = 0
	return b == len(t)
	ali = 0
	ali = 0
for i in range(t):
	ali = 0
	s = list(input().strip())
	ali = 0
	ali = 0
	ali = 0
	n = len(s)
	ali = 0
	ali = 0
	ali = 0
	t = list(input().strip())
	ali = 0
	ali = 0
	ali = 0
	m = len(t)
	ali = 0
	ali = 0
	ali = 0
	diff = (m - n) % 2
	ali = 0
	ali = 0
	ali = 0
	ans1 = search(s, t, 0, 0, diff)
	ali = 0
	ali = 0
	ali = 0
	yn(ans1)
	ali = 0
	ali = 0


for _ in range(int(input())):
	st = input()
	rt = input()
	pt1 = 0
	pt2 = 0
	n = len(st)
	m = len(rt)
	stack = [-1]
	queue = [-2]
	flag = 0
	for i in range(n):
		if pt1 < m and st[i] == rt[pt1] and ((stack[-1] + i) % 2 == 1):
			stack.append(i)
			pt1 += 1
		if pt2 < m and st[i] == rt[pt2] and ((queue[-1] + i) % 2 == 1):
			queue.append(i)
			pt2 += 1
	if pt1 == m and (n - stack[-1]) % 2 == 1:
		print('YES')
	elif pt2 == m and (n - queue[-1]) % 2 == 1:
		print('YES')
	else:
		print('NO')


from __future__ import print_function
import math
from collections import deque
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
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

def inp():
	return int(input())

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

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

def invr():
	return map(int, input().split())
for _ in range(inp()):
	l = input()
	m = input()
	a = len(l)
	b = len(m)
	if b > a:
		print('NO')
		continue
	diff = a - b
	if diff % 2 == 1:
		l = l[1:]
		diff -= 1
		a -= 1
	f = 1
	mp = 0
	prev = -1
	for i in range(a):
		if l[i] == m[mp]:
			if (i - prev - 1) % 2 == 0:
				mp += 1
				prev = i
		diff = a - i - 1 - (b - mp)
		if diff < 0:
			f = 0
			break
		if mp == b:
			break
	if f:
		print('YES')
	else:
		print('NO')


def check(s, t):
	s += '$'
	t += '$'
	j = len(s) - 1
	for i in range(len(t) - 1, -1, -1):
		while j >= 0 and s[j] != t[i]:
			j -= 2
		if j < 0:
			return False
		j -= 1
	return True

def main():
	t = int(input())
	for _ in range(t):
		s = input()
		t = input()
		if check(s, t):
			print('YES')
		else:
			print('NO')
main()


from sys import stdin
from collections import deque
input = stdin.readline

def func():
	st = deque()
	first = len(s) - 1
	second = len(t) - 1
	while -1 < first and -1 < second:
		if s[first] == t[second]:
			st.appendleft(s[first])
			first -= 1
			second -= 1
		else:
			first -= 2
	print('Yes' if list(st) == t else 'No')
for _ in range(int(input())):
	s = list(input())
	t = list(input())
	func()


ntests = int(input())
for _ in range(ntests):
	s = input()
	t = input()
	ns = len(s)
	nt = len(t)
	if ns < nt:
		print('NO')
	else:
		answer = 'YES'
		while nt > 0:
			nt -= 1
			ns -= 1
			while t[nt] != s[ns]:
				if ns < 2 or ns < nt:
					answer = 'NO'
					nt = -1
					break
				ns -= 2
		print(answer)


r = int(input())
for _ in range(r):
	s = input()
	t = input()
	try:
		for c in t[::-1]:
			no = True
			i = len(s) - 1
			while i >= 0:
				if s[i] != c:
					i -= 2
				else:
					s = s[:i]
					no = False
					break
			if no:
				print('NO')
				break
		if not no:
			print('YES')
	except ValueError:
		print('NO')
		continue


def solve(s, t):
	(i, j) = (len(s) - 1, len(t) - 1)
	while j >= 0 and i >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j < 0:
		print('YES')
	else:
		print('NO')
for _ in range(int(input())):
	(s, t) = (input(), input())
	solve(s, t)


for _ in range(int(input())):
	s = str(input())
	t = str(input())
	if len(s) < len(t):
		print('NO')
	else:
		a = len(s) - 1
		b = len(t) - 1
		while 1:
			if a < 0 or b < 0:
				break
			if s[a] == t[b]:
				b -= 1
				a -= 1
			else:
				a -= 2
		print('YES' if b < 0 else 'NO')


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	S = input().strip()
	T = input().strip()
	if len(T) > len(S):
		print('NO')
		continue
	if T == S[len(S) - len(T):]:
		print('YES')
		continue
	LEN = len(S)
	NEXT = [[-10] * 26 for i in range(LEN + 2)]
	for i in range(LEN - 1, -1, -1):
		for j in range(26):
			NEXT[i][j] = NEXT[i + 2][j]
		NEXT[i][ord(S[i]) - 97] = i
	NOW = 0
	for t in T:
		NOW = NEXT[NOW][ord(t) - 97] + 1
		if NOW < 0:
			break
	if NOW >= 0 and (LEN - NOW) % 2 == 0:
		print('YES')
		continue
	NOW = 1
	for t in T:
		NOW = NEXT[NOW][ord(t) - 97] + 1
		if NOW < 0:
			break
	if NOW >= 1 and (LEN - NOW) % 2 == 0:
		print('YES')
		continue
	print('NO')


t = int(input())
while t > 0:
	t -= 1
	s = input()
	a = input()
	last = len(s)
	fl = True
	j = len(a) - 1
	for i in range(len(s) - 1, -1, -1):
		if a[j] == s[i]:
			if (last - i - 1) % 2 == 0:
				last = i
				j -= 1
		if j < 0:
			break
	if j < 0:
		print('YES')
	else:
		print('NO')


q = int(input())

def solve(s, t):
	m = len(s)
	n = len(t)
	if m % 2 != n % 2:
		s = s[1:]
		m -= 1
	if m < n:
		return False
	u = []
	cnt = 0
	for i in range(m):
		if cnt == 0:
			u.append(s[i])
			cnt += 1
		elif cnt == n + 1:
			u.pop()
			cnt -= 1
		elif u[cnt - 1] == t[cnt - 1]:
			u.append(s[i])
			cnt += 1
		elif t[cnt - 1] != u[cnt - 1]:
			u.pop()
			cnt -= 1
	return ''.join(u) == t
for ind in range(q):
	s = input()
	t = input()
	print('Yes' if solve(s, t) else 'No')


def twoPairs(s, t):
	(i, j) = (len(s) - 1, len(t) - 1)
	if i < j:
		return 'NO'
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
		if j == -1:
			return 'YES'
	return 'NO'
n = int(input())
A = []
for i in range(n):
	s = input()
	t = input()
	A.append(twoPairs(s, t))
for i in A:
	print(i)


def isPosible(s, t):
	string = s[::-1]
	wanted = t[::-1]
	i_string = 0
	i_wanted = 0
	while i_wanted < len(wanted) and i_string < len(string):
		if string[i_string] == wanted[i_wanted]:
			i_string += 1
			i_wanted += 1
		else:
			i_string += 2
	if i_wanted == len(wanted):
		return 'YES'
	else:
		return 'NO'
for _ in range(int(input())):
	print(isPosible(input(), input()))


import atexit, io, sys, collections, math, heapq, fractions, copy, os, functools
import sys
import random
import collections
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')

def g(s, parity, i, t):
	k = 1
	if k == len(t):
		j = i + 1
		return (len(s) - j) % 2 == 0
		return True
	parity = 1 - parity
	for j in range(i + 1, len(s)):
		if t[k] == s[j] and parity == j % 2:
			k += 1
			parity = 1 - parity
		if k == len(t):
			return (len(s) - (j + 1)) % 2 == 0
			return True
	return False

def f(s, t):
	s = list(s)
	t = list(t)
	seen = set([])
	for i in range(len(s)):
		if s[i] == t[0]:
			if i % 2 not in seen:
				seen.add(i % 2)
				if g(s, i % 2, i, t):
					return True
	return False
for u in range(int(input())):
	(s, t) = (input(), input())
	print('YES' if f(s, t) else 'NO')


a = int(input())
for i in range(0, a):
	A = input()
	B = input()
	p = False
	L1 = len(A)
	L2 = len(B)
	i = L1 - 1
	j = L2 - 1
	T = 0
	while i >= 0 and j >= 0:
		if A[i] == B[j]:
			i = i - 1
			j = j - 1
			p = True
			T = T + 1
		else:
			i = i - 2
			p = False
	if T == L2:
		print('Yes')
	else:
		print('No')


def solve(s, t):
	(ns, nt) = (len(s), len(t))
	latest = ns
	for i in range(nt - 1, -1, -1):
		c = t[i]
		z = latest - 1
		found = False
		while z >= 0:
			if s[z] == c:
				found = True
				latest = z
				break
			z -= 2
		if not found:
			return False
	return True

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


def solver(s, t):
	si = len(s)
	ti = len(t)
	while si and ti:
		si -= 1
		if s[si] == t[ti - 1]:
			ti -= 1
		elif si:
			si -= 1
	print('NO' if ti else 'YES')
for _ in range(int(input())):
	s = input()
	t = input()
	solver(s, t)


from sys import stdin
input = stdin.readline
from collections import deque as dq

def f(s, t):
	temp = dq(list(t))
	if len(s) < len(t):
		return 'NO'
	i = len(s) - 1
	while i >= 0:
		if s[i] == temp[-1]:
			temp.pop()
			if len(temp) == 0:
				return 'YES'
		else:
			i -= 1
		i -= 1
	return 'NO'
for i in range(int(input())):
	s = input().strip()
	t = input().strip()
	print(f(s, t))


def backspace(s, t):
	if len(s) < len(t):
		return 'NO'
	if s == t:
		return 'YES'
	if len(s) == len(t) and s != t:
		return 'NO'
	i = len(s) - 1
	j = len(t) - 1
	while i > -1 and j > -1:
		if s[i] == t[j]:
			if j == 0:
				return 'YES'
			else:
				i -= 1
				j -= 1
		else:
			i -= 2
	return 'NO'
num_tests = int(input())
for i in range(num_tests):
	s = input()
	t = input()
	print(backspace(s, t))


for i in range(int(input())):
	s = input()
	t = input()
	(n, m) = (len(s), len(t))
	if m > n:
		print('NO')
	else:
		if (n + m) % 2 == 1:
			s = s[1:]
			n = n - 1
		i = 0
		f = 0
		for ch in t:
			while i < n and s[i] != ch:
				i += 2
			if i >= n:
				f = 1
				print('NO')
				break
			i += 1
		if not f:
			print('YES')


def solve(s, t):
	m = len(s)
	n = len(t)
	if m < n:
		return 'NO'
	if m == n:
		if s == t:
			return 'YES'
		else:
			return 'NO'
	cnt = 0
	rgt = n - 1
	for i in range(m - 1, -1, -1):
		if rgt < 0:
			return 'YES'
		if s[i] == t[rgt]:
			if cnt % 2 == 0:
				rgt -= 1
				cnt = 0
				continue
			else:
				cnt += 1
		else:
			cnt += 1
	if rgt >= 0:
		return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	s = input()
	t = input()
	print(solve(s, t))


c = int(input())
for _ in range(c):
	s = input()
	t = input()
	si = len(s) - 1
	ti = len(t) - 1
	while si >= 0 and ti >= 0:
		if s[si] == t[ti]:
			ti = ti - 1
			si = si - 1
		else:
			si = si - 2
	if ti < 0:
		print('YES')
	else:
		print('NO')


import math
import sys
import collections
import bisect
import time
import random
from itertools import permutations

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	s1 = list(get_string())
	s2 = list(get_string())
	if len(s2) > len(s1):
		print('NO')
		continue
	elif s1 == s2:
		print('YES')
		continue
	s1 = s1[::-1]
	s2 = s2[::-1]
	poss = False
	i = 0
	j = 0
	while i < len(s2) and j < len(s1):
		if s2[i] == s1[j]:
			i += 1
			j += 1
		else:
			done = False
			for k in range(j + 1, len(s1)):
				if s1[k] == s2[i]:
					gap = k - j
					if gap % 2 == 0:
						j = k + 1
						done = True
						break
			if done:
				i += 1
			else:
				break
		if i == len(s2):
			poss = True
	if poss:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	s = input()[:-1]
	t = input()[:-1]
	n = len(s)
	m = len(t)
	p = n - 1
	q = m - 1
	while p >= 0:
		if q == -1:
			break
		if s[p] != t[q]:
			p -= 2
		else:
			q -= 1
			p -= 1
	if q == -1:
		print('Yes')
	else:
		print('No')


from sys import stdin, gettrace
if gettrace():

	def inputi():
		return input()
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve(ss, tt):
	dp = [0] * len(ss)
	p = (len(ss) - len(tt)) % 2
	for t in tt:
		while p < len(ss) and ss[p] != t:
			p += 2
		if p >= len(ss):
			break
		p += 1
	else:
		return True
	return False

def main():
	t = int(input())
	sstt = [(input(), input()) for _ in range(t)]
	for (ss, tt) in sstt:
		if solve(ss, tt):
			print('YES')
		else:
			print('NO')
main()


q = int(input())
for x in range(q):
	s = list(input()[::-1])
	t = list(input()[::-1])
	temp = []
	it = 0
	while it < len(s):
		if s[it] == t[len(temp)]:
			temp.append(s[it])
		else:
			it += 1
		if temp == t:
			break
		it += 1
	if temp == t:
		print('YES')
	else:
		print('NO')


import sys

def main():
	num_tests = int(sys.stdin.readline())
	for _ in range(num_tests):
		s = sys.stdin.readline()
		t = sys.stdin.readline()
		print('YES' if is_possible(s, t) else 'NO')

def is_possible(s: str, t: str) -> bool:
	if solve(s, t, 1):
		return True
	return solve(s, t, 0)

def solve(s: str, t: str, initial_mod: int) -> bool:
	i = 0
	j = 0
	cur_mod = initial_mod
	while i < len(s) and j < len(t):
		if s[i] == t[j] and i % 2 == cur_mod:
			j += 1
			cur_mod = 1 if cur_mod == 0 else 0
		i += 1
	return j == len(t) and (len(s) - i) % 2 == 0
main()


q = int(input())
for _ in range(q):
	s = input()[::-1]
	t = input()[::-1]
	s_index = 0
	t_index = 0
	while s_index < len(s) and t_index < len(t):
		if s[s_index] == t[t_index]:
			s_index += 1
			t_index += 1
		else:
			s_index += 2
	if t_index == len(t):
		print('YES')
	else:
		print('NO')


def solve(s, t, start):
	z = start
	cnt = 0
	n = len(s)
	m = len(t)
	latest = n - 1
	while z < n and cnt < m:
		if s[z] == t[cnt]:
			latest = z
			z += 1
			cnt += 1
		else:
			z += 2
	return cnt == m and (n - latest) % 2

def main():
	q = int(input())
	for _ in range(q):
		s = input()
		t = input()
		if solve(s, t, 0) or solve(s, t, 1):
			print('YES')
		else:
			print('NO')
main()


n = int(input())
for _ in range(n):
	s = input()
	t = input()
	i = len(s) - 1
	fail = False
	for c in t[::-1]:
		while i >= 0 and c != s[i]:
			i -= 2
		if i < 0 or (i == 0 and s[0] != c):
			fail = True
			break
		i -= 1
	print('NO' if fail else 'YES')


def solve() -> bool:
	string = input()
	target = input()
	string_len = len(string)
	target_len = len(target)
	if string_len < target_len:
		return False
	q = k = 0
	for i in range((string_len - target_len) % 2, string_len):
		if k == 1:
			k = 0
			continue
		if q < target_len and string[i] == target[q]:
			q += 1
		else:
			k += 1
	return q == target_len
for _ in range(int(input())):
	print('YES' if solve() else 'NO')


from collections import deque
N = int(input())
answer = []
for _ in range(N):
	(s, t) = (deque(input()[::-1]), deque(input()[::-1]))
	while s and t:
		if s[0] == t[0]:
			s.popleft()
			t.popleft()
		else:
			s.popleft()
			if s:
				s.popleft()
	print('YES' if len(t) == 0 else 'NO')


import math
for _ in range(int(input())):
	A = input()
	B = input()
	(j, k) = (len(A) - 1, len(B) - 1)
	while j >= 0 and k >= 0:
		if A[j] == B[k]:
			k -= 1
			j -= 1
		else:
			j -= 2
	if k == -1:
		print('YES')
	else:
		print('NO')


def solve(s, t):
	n = len(s)
	m = len(t)
	if n < m:
		return False
	p = n - m & 1
	q = 0
	k = 0
	for i in range(p, n):
		if k == 1:
			k = 0
			continue
		if q < m and s[i] == t[q]:
			q += 1
		else:
			k += 1
	return q == m
n = int(input())
for x in range(n):
	s = input()
	t = input()
	if solve(s, t):
		print('YES')
	else:
		print('NO')


def main():
	S = input()[::-1]
	T = input()[::-1]
	Skip = 0
	j = 0
	for i in range(len(S)):
		if Skip:
			Skip = 0
		elif S[i] == T[j]:
			j += 1
			if j == len(T):
				break
		else:
			Skip = 1
	else:
		return print('NO')
	print('YES')
T = int(input())
for _ in range(T):
	main()


answers = []
for _ in range(int(input())):
	s = input()
	t = input()
	i = len(s) - 1
	j = len(t) - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		answers.append('YES')
	else:
		answers.append('NO')
for ans in answers:
	print(ans)


rint = lambda : int(input())
rli = lambda : list(map(int, input().split()))
rl = lambda : input().split()

def strm(m):
	s = ''
	for i in range(len(m)):
		for j in range(len(m[0])):
			s += str(m[i][j])
		s += '\n'
	return s

def solve():
	s = input()
	t = input()
	if len(s) < len(t):
		return 'NO'
	if s == t:
		return 'YES'
	if s[-len(t):] == t:
		return 'YES'
	k = len(s) - 1
	j = len(t) - 1
	while j > -1 and k >= 0:
		if s[k] == t[j]:
			k -= 1
			j -= 1
		else:
			k -= 2
	if j == -1:
		return 'YES'
	return 'NO'
res = ''
for test_number in range(1, rint() + 1):
	r = solve()
	print(r)
	res += r + '\n'


t = int(input())
for _ in range(t):
	a = input()
	b = input()
	i = len(a) - 1
	j = len(b) - 1
	while i > -1 and j > -1:
		if a[i] == b[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		print('YES')
	else:
		print('NO')


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 = list(input().strip())
	b = input().strip()
	k = len(b) - 1
	while k >= 0 and a:
		if a[-1] == b[k]:
			a.pop()
			k -= 1
		else:
			if a:
				a.pop()
			if a:
				a.pop()
	if k == -1:
		print('YES')
	else:
		print('NO')


import sys
import math
import collections
import heapq
import decimal
input = sys.stdin.readline
t = int(input())
for w in range(t):
	s = input()
	s1 = input()
	n1 = len(s) - 1
	n2 = len(s1) - 1
	i = n1 - 1
	j = n2 - 1
	while i >= 0 and j >= 0:
		if s[i] == s1[j]:
			i -= 1
			j -= 1
		else:
			i -= 2
	if j == -1:
		print('YES')
	else:
		print('NO')


tx = int(input())
for _ in range(tx):
	s = input()
	t = input()
	if len(s) < len(t):
		print('NO')
		continue
	f = 1
	i = len(s) - 1
	for j in range(len(t) - 1, -1, -1):
		while i >= 0 and s[i] != t[j]:
			i -= 2
		if i < 0:
			f = 0
			break
		i -= 1
	if f == 0:
		print('NO')
	else:
		print('YES')


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
INF = 10 ** 10
YES = 'YES'
NO = 'NO'

def solve(S, T):
	if len(T) > len(S):
		return 'NO'
	A0 = [list() for _ in range(26)]
	A1 = [list() for _ in range(26)]
	for i in range(len(S)):
		if i % 2 == 0:
			A0[ord(S[i]) - ord('a')].append(i)
		else:
			A1[ord(S[i]) - ord('a')].append(i)
	(k0, k1) = (-1, -1)
	for c in T:
		d = ord(c) - ord('a')
		l = bisect.bisect_left(A0[d], k1 + 1)
		if l < len(A0[d]):
			k0_next = A0[d][l]
		else:
			k0_next = INF
		l = bisect.bisect_left(A1[d], k0 + 1)
		if l < len(A1[d]):
			k1_next = A1[d][l]
		else:
			k1_next = INF
		k0 = k0_next
		k1 = k1_next
	if (len(S) - 1) % 2 == 0:
		if k0 < INF:
			return 'YES'
		else:
			return 'NO'
	elif k1 < INF:
		return 'YES'
	else:
		return 'NO'
T0 = int(input())
for _ in range(T0):
	S = input()
	T = input()
	print(solve(S, T))