#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  for (long long q = 0; q < n; q++) {
    string s, t;
    cin >> s >> t;
    long long i = 0, j = 0;
    long long ss = s.size();
    long long ts = t.size();
    char cs, ct;
    long long count1 = 0, count2 = 0;
    long long flag = 0;
    while (i < ss || j < ts) {
      cs = s[i];
      ct = t[j];
      count1 = 0;
      count2 = 0;
      if (cs == ct) {
        while (s[i] == cs) {
          count1++;
          i++;
        }
        while (t[j] == ct) {
          count2++;
          j++;
        }
        if (count2 < count1) {
          flag = 1;
          break;
        }
      } else {
        flag = 1;
        break;
      }
    }
    if (flag) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
