#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
void solve() {
  string a, b;
  cin >> a >> b;
  long long int i = 0, j = 0;
  long long int n = a.size(), m = b.size();
  long long int f = 1;
  for (i; i < n; i++) {
    char x = a[i];
    long long int cnt = 0;
    while (i < n && a[i] == x) {
      cnt++;
      i++;
    }
    i--;
    long long int cnt2 = 0;
    for (j; j < m; j++) {
      while (j < m && b[j] == x) {
        cnt2++;
        j++;
      }
      break;
    }
    if (cnt > cnt2) {
      cout << "NO"
           << "\n";
      return;
    }
  }
  if (j >= m)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
