#include <bits/stdc++.h>
using namespace std;
long double const pi = 3.141592653589793238462;
long long int const mod = 1e9 + 7;
long long int power(long long int a, long long int b) {
  long long int f = 1;
  while (b > 0) {
    if (b & 1) {
      f = f * a;
    }
    a = a * a;
    b = b / 2;
  }
  return f;
}
bool rev(long long int a, long long int b) { return a >= b; }
long long int const N = 3e5 + 5;
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    string a, b;
    cin >> a >> b;
    long long int ans = 1;
    long long int i, j, l;
    if (b.size() < a.size()) {
      cout << "NO" << endl;
      continue;
    }
    j = 0;
    for (i = 0; i < a.size(); i++) {
      for (l = i + 1; l < a.size(); l++) {
        if (a[l] != a[i]) break;
      }
      long long int ca = l - i;
      i = l - 1;
      for (l = j; l < b.size(); l++) {
        if (b[l] != a[i]) break;
      }
      long long int cb = l - j;
      if (ca > cb) {
        ans = 0;
        break;
      }
      j = l;
    }
    if (j < b.size()) ans = 0;
    if (ans)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
