#include <bits/stdc++.h>
using namespace std;
void sol() {
  string s, t;
  cin >> s >> t;
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  long long n = s.size(), m = t.size();
  long long ind = 0, j = 0;
  while (ind < m && j < n) {
    if (s[j] == t[ind]) {
      ind++;
      j++;
    } else {
      j += 2;
    }
  }
  cout << (ind == m ? "YES\n" : "NO\n");
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t = 1;
  cin >> t;
  while (t--) {
    sol();
  }
}
