#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int k, tlen, slen;
  char prev = '-1', cur;
  bool first = true;
  string s, t, t1;
  for (int i = 0; i < n; i++) {
    cin >> s;
    cin >> t;
    tlen = t.length();
    slen = s.length();
    for (int j = 0; j < tlen; j++) {
      cur = t[j];
      if (cur == prev) {
        if (first == true) {
          k = j;
          first = false;
        }
        if (s[k] == cur) {
          t1.push_back(cur);
          k++;
        }
      } else {
        k++;
        t1.push_back(cur);
      }
      prev = cur;
    }
    first = true;
    prev = '-1';
    if (s == t1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
    t1.clear();
  }
  return 0;
}
