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