#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  while (n--) {
    string s, t;
    cin >> s >> t;
    bool b = true;
    long long l = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == t[l]) {
        l++;
        if (s[i + 1] == s[i]) continue;
        while (t[l] == s[i]) l++;
      } else {
        b = false;
        break;
      }
    }
    if (l != t.length()) b = false;
    if (b)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
