#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s, s1;
    cin >> s >> s1;
    long long int a = s.size();
    long long int b = s1.size();
    int i = 0, j = 0, c = 0, d = 0, f = 0;
    while (i < a && j < b) {
      c = 1;
      d = 1;
      if (s[i] != s1[j]) {
        cout << "NO" << endl;
        f = 1;
        break;
      }
      while (i < a - 1 && s[i] == s[i + 1]) {
        c++;
        i++;
      }
      while (j < b - 1 && s1[j] == s1[j + 1]) {
        d++;
        j++;
      }
      if (c > d) {
        cout << "NO" << endl;
        f = 1;
        break;
      }
      i++;
      j++;
    }
    if (i == a && j == b) {
      cout << "YES" << endl;
    } else {
      if (f == 0) cout << "NO" << endl;
    }
  }
  return 0;
}
