#include <bits/stdc++.h>
using namespace std;
const double PI = atan(1.0) * 4;
const long long int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string str1, str2;
    cin >> str1 >> str2;
    bool good = true;
    int ptr1 = 0, ptr2 = 0;
    while (ptr1 < str1.length()) {
      int x = 0;
      char ch1 = str1[ptr1];
      while (ptr1 < str1.length() && str1[ptr1] == ch1) {
        ptr1++;
        x++;
      }
      int y = 0;
      char ch2 = str2[ptr2];
      while (ptr2 < str2.length() && str2[ptr2] == ch1) {
        y++;
        ptr2++;
      }
      if (y < x) {
        good = false;
        break;
      }
    }
    if (good && ptr2 >= str2.length())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
