#include <bits/stdc++.h>
using namespace std;
const int N = 305001;
const int SQRT = 350;
const long double PI = acos(-1);
string s[2];
vector<pair<char, int> > v[2];
int t;
int solve() {
  for (int i = 0; i < 2; i++) {
    cin >> s[i];
    v[i].clear();
    v[i].push_back(make_pair(s[i][0], 1));
    for (int j = 1; j < s[i].size(); j++) {
      if (v[i].back().first == s[i][j])
        v[i].back().second++;
      else
        v[i].push_back(make_pair(s[i][j], 1));
    }
  }
  if (v[0].size() != v[1].size()) {
    return puts("NO"), 0;
  }
  for (int i = 0; i < v[0].size(); i++) {
    if (v[0][i].first != v[1][i].first) {
      return puts("NO"), 0;
    }
    if (v[0][i].second > v[1][i].second) {
      return puts("NO"), 0;
    }
  }
  return puts("YES"), 0;
}
signed main() {
  cin >> t;
  while (t--) solve();
}
