#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  bool out = false;
  while (n--) {
    string s;
    string t;
    cin >> s;
    cin >> t;
    long long int s1 = s.length();
    long long int t1 = t.length();
    out = false;
    if (t1 < s1) {
      cout << "NO" << endl;
      out = true;
    } else if (t1 == s1) {
      if (s > t || t > s) {
        cout << "NO" << endl;
      } else
        cout << "YES" << endl;
      out = true;
    } else {
      long long int c1 = 0, c2 = 0;
      long long int it1 = 0, it2 = 0;
      while (it1 < s1) {
        char c = s[it1];
        char a = t[it2];
        if (a != c) {
          cout << "NO" << endl;
          out = true;
          break;
        } else {
          while (s[it1] == c && it1 < s1) {
            c1++;
            it1++;
          }
          while (t[it2] == c && it2 < t1) {
            c2++;
            it2++;
          }
          if (c1 > c2 && !out) {
            cout << "NO" << endl;
            out = true;
            break;
          }
          c1 = 0;
          c2 = 0;
        }
      }
      if (it2 < t1 && !out) {
        cout << "NO" << endl;
        out = true;
      }
      if (!out) cout << "YES" << endl;
    }
  }
  return 0;
}
