#include <bits/stdc++.h>
using namespace std;
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.first);
  cerr << ",";
  _print(p.second);
  cerr << "}";
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
void init_code() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  string a;
  string b;
  cin >> a >> b;
  string ans;
  int n = ((int)(a).size());
  int n1 = ((int)(b).size());
  int j = n1 - 1;
  int flag = 0;
  int i = n - 1;
  while (i >= 0) {
    if (a[i] == b[j]) {
      i--;
      j--;
    } else {
      i -= 2;
    }
    if (j == -1) {
      flag = 1;
      break;
    }
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
  cout << "\n";
}
signed main() {
  init_code();
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
