#!/bin/python3
#Dynamic Programming Abbreviation
import math
import os
import random
import re
import sys

def abbreviationOld(a, b):
    def check(i, j):
        if i == len(a) and j == len(b):
            return True
        elif i < len(a) and j == len(b):
            return checkIfCapital(a, i)
        elif i == len(a) and j < len(b):
            return False
        
        # if i < len(a) and i < len(b):
        #     print(i, a[i], j, b[j])
        if a[i] == b[j]:
            checkMap[i][j] = True
            if checkMap[i+1][j+1] is None:
                checkMap[i+1][j+1] = check(i+1, j+1)
            return checkMap[i+1][j+1]
        else:
            if ord(a[i]) >= 97:
                char = chr(ord(a[i])-32)
                if b[j] == char:
                    if checkMap[i+1][j+1] is None:
                        checkMap[i+1][j+1] = check(i+1, j+1)
                    if checkMap[i+1][j] is None:
                        checkMap[i+1][j] = check(i+1, j)
                    return checkMap[i+1][j] or checkMap[i+1][j+1]
                else:
                    if checkMap[i+1][j] is None:
                        checkMap[i+1][j] = check(i+1, j)
                    return checkMap[i+1][j]
            else:
                checkMap[i][j] = False
                return False

    sys.setrecursionlimit(2000)
    checkMap = [[None for j in range(len(b)+1)] for i in range(len(a)+1)]
    result = check(0, 0)
    if result:
        return "YES"
    else:
        return "NO"
def checkIfCapital(a, idx):
    for i in range(idx, len(a)):
        if ord(a[i]) < 97:
            return False
    return True

def abbreviationNew(a, b):
    checkMap = [[None for j in range(len(b))] for i in range(len(a))]
    i = 0
    j = 0
    while i < len(a) and j < len(b):
        if checkMap[i][j] is None:
            if a[i] == b[j]:
                checkMap[i][j] = 1
                i += 1
                j += 1
            else:
                if ord(a[i]) >= 97:
                    char = chr(ord(a[i])-32)
                    if char == b[j]:
                        checkMap[i][j] = 1
                        i += 1
                        j += 1
                    else:
                        checkMap[i][j] = 0
                        i += 1

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    q = int(input())

    for q_itr in range(q):
        a = input()

        b = input()

        result = abbreviation(a, b)

        fptr.write(result + '\n')

    fptr.close()

    fptr.close()
