#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n;
  cin >> n;
  while (n--) {
    string a, b;
    cin >> a;
    cin >> b;
    long long int i = 0, j = 0;
    if (a[i] != b[j])
      cout << "NO\n";
    else {
      while (j < b.length()) {
        if (a[i + 1] == b[j + 1])
          i++, j++;
        else if (a[i] == b[j + 1])
          j++;
        else {
          cout << "NO\n";
          break;
        }
      }
      if (j == b.length()) cout << "YES\n";
    }
  }
}
