#include <bits/stdc++.h>
using namespace std;
long long n, i, j, k;
string s[300005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (i = 0; i < 2 * n; i++) {
    cin >> s[i];
  }
  for (i = 0; i < 2 * n; i += 2) {
    bool no = false;
    char curr;
    k = 0;
    for (j = 0; j < s[i].length(); j++) {
      int cntwo = 1;
      bool two = false;
      curr = s[i][j];
      while (j < s[i].length() - 1 && s[i][j + 1] == curr) {
        two = true;
        cntwo++;
        j++;
      }
      if (two) {
        if (s[i + 1][k] != curr) {
          no = true;
          break;
        } else {
          int cnt = 0;
          while (k < s[i + 1].length() && s[i + 1][k] == curr) {
            cnt++;
            k++;
          }
          if (cnt < cntwo) {
            no = true;
            break;
          }
        }
      } else {
        if (s[i + 1][k] != curr) {
          no = true;
          break;
        }
        while (k < s[i + 1].length() && s[i + 1][k] == curr) k++;
      }
    }
    if (k < s[i + 1].length()) no = true;
    if (no)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
