#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  for (i = 0; i < n; i++) {
    string a, b;
    cin >> a >> b;
    int j, k, c, d, r, n, m;
    n = 0;
    r = 0;
    j = 0;
    c = 0;
    d = 0;
    while (j < a.size() && n < b.size()) {
      if (a[j] == b[n]) {
        k = j + 1;
        while (a[k] == a[j]) {
          c++;
          k++;
        }
        j = k;
        m = n + 1;
        while (b[m] == b[n]) {
          d++;
          m++;
        }
        n = m;
        if (d >= c) {
          d = 0;
          c = 0;
          continue;
        } else {
          r++;
          break;
        }
      } else {
        r++;
        break;
      }
    }
    if (r == 0 && j == a.size() && n == b.size())
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
  }
}
