#include <bits/stdc++.h>
using namespace std;
int n, j, k;
string a, b;
char aux;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  while (cin >> n) {
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      if (a[0] != b[0] || b.size() < a.size())
        cout << "NO\n";
      else {
        int i, j;
        char c;
        for (i = j = 0; j < b.size();) {
          if (a[i] == b[j]) {
            i++;
            j++;
          } else {
            if (b[j] == a[i - 1]) {
              j++;
            } else {
              break;
            }
          }
        }
        if (j == b.size() && i == a.size())
          cout << "YES\n";
        else
          cout << "NO\n";
      }
    }
  }
  return 0;
}
