#include <bits/stdc++.h>
using namespace std;
int T, sum = 0;
string a, b;
int main() {
  cin >> T;
  while (T--) {
    int temp = 0, flag = 0;
    cin >> a;
    cin >> b;
    int k = 0;
    int LA = a.size();
    int LB = b.size();
    for (int i = 0; i <= LA; i++) {
      if (flag == 0 && a[i] != b[k]) {
        while (b[k] == b[k - 1]) {
          k++;
        }
        flag = 1;
      }
      if (a[i] == b[k]) {
        k++;
        flag = 0;
        continue;
      }
      if (flag == 1) {
        cout << "NO" << endl;
        temp = 1;
        break;
      }
    }
    if (temp == 0) {
      cout << "YES" << endl;
    }
  }
  return 0;
}
