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