#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long tt;
  cin >> tt;
  while (tt--) {
    string s1, s2;
    cin >> s1 >> s2;
    long long i = s1.size(), j = s2.size();
    while (i > 0 && j > 0) {
      if (s1[i - 1] == s2[j - 1]) {
        i--;
        j--;
      } else {
        i -= 2;
      }
    }
    if (j <= 0) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }
  }
}
