#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
long long tc, l, k, sum, x, y, z, m = 1, n;
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> tc;
  while (tc--) {
    string s, t;
    sum = 0;
    cin >> s;
    l = s.size();
    cin >> t;
    m = t.size();
    x = 0;
    long long i, j;
    for (i = 0, j = 0; t[i]; i++) {
      if (t[i] == s[j])
        j++;
      else if (t[i] != t[i - 1])
        break;
    }
    if (i == m && j == l)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
