#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  for (long long z = 0; z < t; z++) {
    long long c = 0, d = 0, f = 0, j = 0, g = 0;
    string a, b;
    cin >> a;
    cin >> b;
    for (long long i = 0; i < a.size(); i++) {
      if (a[i] == a[i + 1])
        c++;
      else if (a[i] == b[j]) {
        for (j; j < b.size(); j++) {
          if (b[j] == b[j + 1]) {
            d++;
          } else {
            j++;
            break;
          }
        }
        if (d < c) {
          f++;
        }
        c = 0;
        d = 0;
      } else {
        g++;
        break;
      }
    }
    if (f == 0 && g == 0 && b[j] == '\0')
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
