#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  string s, s1;
  cin >> n;
  while (n--) {
    cin >> s >> s1;
    j = 0;
    int count = 0;
    for (i = 0; i < s1.size(); i++) {
      if (s1[i] == s[j]) j++;
      if (s1[i] != s[j] && s1[i] != s[j - 1]) {
        count = 1;
        break;
      }
    }
    if (j == s.size() && count == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
