#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
template <typename... T>
void debug(T &&...args) {
  ((cerr << args << " "), ...);
  cerr << "\n";
}
long long int gcd(long long int a, long long int b) {
  return a ? gcd(b % a, a) : b;
}
long long int minv(long long int a, long long int b) { return a < b ? a : b; }
long long int maxv(long long int a, long long int b) { return a > b ? a : b; }
void swapv(long long int &a, long long int &b) {
  a = a + b;
  b = a - b;
  a = a - b;
}
long long int power(long long int a, long long int b, long long int m = mod) {
  if (a == 0 || b == 1) return a;
  if (b == 0) return 1;
  long long int ans = 1;
  while (b >= 1) {
    if (b & 1) {
      b--;
      ans = (ans * a) % m;
    }
    a = (a * a) % m;
    b = b >> 1;
  }
  return ans;
}
long long int logv(long long int x) {
  long long int ans = -1;
  while (x) {
    x = x >> 1;
    ans++;
  }
  return ans;
}
long long int inv(long long int a, long long int m) {
  return power(a, m - 2, m);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  cin >> t;
  while (t--) {
    string s, p;
    cin >> s >> p;
    int l1 = s.length();
    int l2 = p.length();
    int s1 = l1 - 1, p1 = l2 - 1;
    while (s1 >= 0 && p1 >= 0) {
      if (s[s1] == p[p1]) {
        s1--;
        p1--;
        continue;
      }
      s1 -= 2;
    }
    if (p1 >= 0) {
      cout << "NO";
      cout << "\n";
      ;
    } else {
      cout << "YES";
      cout << "\n";
      ;
    }
  }
  return 0;
}
