#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  while (n--) {
    string first, second;
    cin >> first >> second;
    long long j = 0, i, sum1 = 0, sum2 = 0;
    bool flag = false;
    if (second.length() < first.length())
      flag = true;
    else
      for (i = 0; i < second.length(); i++) {
        long long s1 = 0, s2 = 0;
        char c = first[j];
        if (c != second[i]) {
          flag = true;
          break;
        }
        while (first[j + 1] == c) {
          j++;
          s1++;
          sum1++;
        }
        while (second[i + 1] == c) {
          i++;
          s2++;
          sum2++;
        }
        if (s2 < s1) {
          flag = true;
          break;
        }
        j++;
      }
    if (flag || second.length() - sum2 != first.length() - sum1)
      cout << "NO";
    else
      cout << "YES";
    cout << endl;
  }
}
