#include <bits/stdc++.h>
using namespace std;
void solve() {
  string a, b;
  cin >> a >> b;
  int n = a.size();
  int m = b.size();
  if (m > n) {
    cout << "NO" << endl;
    return;
  }
  int here = n - 1, k = n;
  bool ok = true;
  for (int i = m - 1; i >= 0; i--) {
    while (here > 1 && a[here] != b[i]) {
      here -= 2;
    }
    if (a[here] != b[i]) {
      ok = false;
      break;
    }
    here--;
  }
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
