#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int j = 0, flag = 0;
    string s1, s2;
    cin >> s1 >> s2;
    for (long long int i = 0; i < s1.size(); i++) {
      if (s1[i] != s2[j]) {
        cout << "NO" << endl;
        flag = 1;
        break;
      }
      if (s1[i + 1] == s1[i])
        j++;
      else {
        while (j < s2.size() && s2[j] == s1[i]) j++;
      }
    }
    if (flag == 0) {
      if (j != s2.size())
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
    }
  }
  return 0;
}
