#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t = 0;
  cin >> t;
  while (t--) {
    string a;
    string b;
    cin >> a >> b;
    bool r = true;
    int i = 0;
    int j = 0;
    int k = 0;
    int l = 0;
    int alpha1[26] = {0};
    int alpha2[26] = {0};
    while (i < a.length()) {
      if ((a[i] != b[k]) || (k < i)) {
        r = false;
        break;
      }
      j = i;
      l = k;
      while (i < a.length() && a[i] == a[j]) {
        alpha1[a[i++] - 0x61]++;
      }
      while (k < b.length() && b[k] == a[j]) {
        alpha2[b[k++] - 0x61]++;
      }
      if ((k - l) < (i - j)) {
        r = false;
        break;
      }
    }
    if ((k < b.length() && a[i - 1] != b[k]) || (k < i)) {
      r = false;
    }
    if (r == true) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
