#include <bits/stdc++.h>
using namespace std;
int t;
int main() {
  scanf("%d", &t);
  while (t--) {
    string s1, s2;
    cin >> s1 >> s2;
    int len1 = s1.size();
    int len2 = s2.size();
    if (len2 < len1)
      cout << "NO" << endl;
    else {
      int k = 0, flag = 0, p;
      char ch = s1[k];
      if (ch != s2[0])
        flag = 0;
      else {
        char tmp;
        for (int i = 0; i < len2; i++) {
          if (s2[i] == ch) {
            k++;
            if (k == len1) {
              flag = 1;
              ch = s1[k - 1];
              p = i;
              break;
            }
            tmp = s2[i];
            ch = s1[k];
          } else {
            ch = s1[k];
            if (s2[i] != tmp) break;
          }
        }
        for (int i = p; i < len2; i++) {
          if (s2[i] != ch) {
            flag = 0;
            break;
          }
        }
      }
      if (flag)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
