#include<conio.h>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;++i)
const int maxn=1e5+5;
char a[maxn],b[maxn];
bool check()
{
int la=strlen(a),lb=strlen(b);
int i=0,j=0;
while(i<la-1&&a[i]==a[i+1])i++;
while(j<lb-1&&b[j]==b[j+1])j++;
if(i<j||a[0]!=b[0])return false;
i=++j;
for(;i<la;++i,++j)
{
while(j<lb&&b[j]!=a[i])j++;
if(j==lb)return false;
}
return true;
}
int main()
{
//freopen("Input.txt","r",stdin);
int T;scanf("%d",&T);
while(T--)
{
scanf("%s%s",a,b);
if(check())printf("Yes
");
else printf("No
");
}
}