#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define lop(k,n) for(int i=k;i<n;i++)
#define int long long
#define sz(x) long(x.size())
#define te int t;cin>>t;while(t--)
#define el '\n'
#define pi pair<int,int>
void sol(){
string a,b;cin>>a>>b;
int ok=1;
int x=1;
if(a[0]==b[0]){
for (int i=1;i<b.size();i++){
if(b[i]==a[x])x++;
else if(b[i]!=b[i-1])ok=0;
}
}
else ok=0;
if(ok&&x==sz(a))yes;else no;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
te sol();
}
228A - Is your horseshoe on the other hoof | 122A - Lucky Division |
1611C - Polycarp Recovers the Permutation | 432A - Choosing Teams |
758A - Holiday Of Equality | 1650C - Weight of the System of Nested Segments |
1097A - Gennady and a Card Game | 248A - Cupboards |
1641A - Great Sequence | 1537A - Arithmetic Array |
1370A - Maximum GCD | 149A - Business trip |
34A - Reconnaissance 2 | 59A - Word |
462B - Appleman and Card Game | 1560C - Infinity Table |
1605C - Dominant Character | 1399A - Remove Smallest |
208A - Dubstep | 1581A - CQXYM Count Permutations |
337A - Puzzles | 495A - Digital Counter |
796A - Buying A House | 67A - Partial Teacher |
116A - Tram | 1472B - Fair Division |
1281C - Cut and Paste | 141A - Amusing Joke |
112A - Petya and Strings | 677A - Vanya and Fence |