#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int mod = 1000000007;
bool remender(long long a, long long b) { return a % b; }
void solve() {
  string a, b;
  cin >> a >> b;
  if (a.size() > b.size()) {
    cout << "NO\n";
    return;
  }
  int n = a.size();
  int m = b.size();
  int k = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 1;
    int j = i + 1;
    while (j < n && a[j] == a[j - 1]) cnt++, j++;
    int c = 0;
    while (k < m && b[k] == a[i]) {
      k++;
      c++;
    }
    if (c < cnt) {
      cout << "NO\n";
      return;
    }
    i = j - 1;
  }
  if (k < m) {
    cout << "NO\n";
    return;
  }
  cout << "YES\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
