#include <bits/stdc++.h>
using namespace std;
const long long I1 = 1e9 + 7;
const long long I2 = 1e18;
const long long MAXM = 1e5 + 5;
template <typename T, typename T1>
T maxn(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T minn(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
bool isPrime(long long int n) {
  if (n <= 1) return false;
  for (long long int i = 2; i < n; i++)
    if (n % i == 0) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int j = t.length() - 1;
    for (int i = n - 1; i >= 0 && j >= 0;) {
      if (s[i] == t[j]) {
        i--;
        j--;
      } else
        i -= 2;
    }
    if (j < 0)
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
  }
  return 0;
}
