#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
long long n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1, i, j, k;
  cin >> t;
  while (t--) {
    map<char, long long> m1, m2;
    string a, b;
    cin >> a >> b;
    j = 0;
    for (i = 0; i < a.size();) {
      long long cnt_f = 1;
      while (i < (a.size() - 1) && a[i] == a[i + 1]) i++, cnt_f++;
      long long cnt_s = 0;
      while (j < b.size() && b[j] == a[i]) j++, cnt_s++;
      if (cnt_s < cnt_f) {
        break;
      }
      i++;
    }
    if (i >= a.size() && j >= b.size())
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
  }
  return 0;
}
