#include <bits/stdc++.h>   using namespace std;   long long n, m, q, t, x, y, b, c, d;   string s1, s2;   long long a[3];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s1 >> s2;       int l1 = s1.length();       int l2 = s2.length();       int j = 0, k = 0;       int ok = 1;       int lastok = -1;       while (j < l1 && k < l2) {         if (s1[j] == s2[k]) {           j++;           k++;           lastok++;         } else if (k && s2[k] == s2[k - 1]) {           int tmp = k;           while (tmp < l2 && s2[tmp] == s2[k]) tmp++;           if (tmp == l2) {             ok = 0;             break;           }           lastok = tmp - 1;           k = tmp;         } else if (lastok == k - 1) {           ok = 0;           break;         }       }       if (j < l1) ok = 0;       while (k < l2) {         if (k && s2[k] != s2[k - 1]) {           ok = 0;           break;         }         k++;       }       cout << (ok ?  YES  :  NO ) << endl;     }     return 0;   }   