#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define ll long long int
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define mx_ele(v) *max_element(v.begin(),v.end())
#define mnm_ele(v) *min_element(v.begin(),v.end())
#define endl "\n"
using namespace std;
void smile()
{
string s;
cin>>s;
string s1;
cin>>s1;
vector<int>pos;
int start=0;
for(int i=0;i<s1.size();i++)
{
int flag=0;
for(int j=0; j<s.size(); j++)
{
if(s1[i]==s[j])
{
int temp=j+1;
if(temp>start)
{
pos.pb(temp);
start=temp;
flag=1;
break;
}
}
}
if(flag==0)
break;
}
if(pos.size()==s1.size())
{
int flag1=0;
for(int i=0; i<pos.size()-1; i++)
{
if(pos[i]>=pos[i+1])
{
flag1=1;
break;
}
}
if(flag1==1)
no;
else
yes;
}
else
no;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
cin>>T;
while(T--)
{
smile();
}
}