#include <bits/stdc++.h>
using namespace std;
int main() {
  int p;
  cin >> p;
  while (p--) {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    int i = 0, j = 0, f = 0;
    char c;
    while (i < n && j < m) {
      if (n > m) {
        f = 1;
        break;
      }
      while (s[i] == t[j] && s[i] == s[i + 1]) {
        i++;
        j++;
      }
      if (s[i] != t[j]) {
        f = 1;
        break;
      }
      while (s[i] == t[j]) j++;
      i++;
    }
    if (i == n && j == m)
      cout << "YES";
    else
      cout << "NO";
    cout << "\n";
  }
  return 0;
}
