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