#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
const int INF = 0x3f3f3f3f;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    string s, t;
    cin >> s >> t;
    int poss = 0, post = 0;
    while (post < t.length()) {
      if (s[poss] == t[post]) {
        if (poss + 1 != s.length() && s[poss + 1] == s[poss]) {
          ++poss;
          ++post;
        } else {
          while (t[post] == s[poss]) ++post;
          ++poss;
        }
      } else
        goto failed;
    }
    if (poss != s.length()) goto failed;
    cout << "YES\n";
    continue;
  failed:
    cout << "NO\n";
  }
}
