#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1000000007;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    string second;
    cin >> second;
    string test;
    cin >> test;
    long long n = second.size();
    long long m = test.size();
    long long i, j;
    for (i = n - 1, j = m - 1; i >= 0 && j >= 0; j) {
      if (second[i] == test[j]) {
        i--;
        j--;
      } else
        i -= 2;
    }
    if (j >= 0 && i < 0)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
