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