#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string a, b;
    cin >> b >> a;
    int i_b = 0;
    int i_a = 0;
    int found = 0;
    while (i_a < a.size() && i_b < b.size()) {
      int b_count = 1;
      while (i_b < b.size() &&
             (i_b < b.size() - 1 ? b[i_b] == b[i_b + 1] : 0)) {
        i_b++;
        b_count++;
      }
      int a_count = 0;
      while (i_a < a.size() && a[i_a] == b[i_b]) {
        i_a++;
        a_count++;
      }
      if (a_count < b_count) {
        found = -1;
        break;
      }
      i_b++;
    }
    if (found == 0 && i_a == a.size() && i_b == b.size()) {
      found = 1;
    } else if (found == -1) {
      found = 0;
    }
    if (found)
      cout << "YES" << endl;
    else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
