#include <iostream>
using namespace std;
string s, sub;
bool check(int it, int pos) {
if(it >= s.length()) {
if(pos >= sub.length()) {
return true;
} else {
return false;
}
}
if(pos >= sub.length()) {
return true;
}
if(s[it] != sub[pos]) {
return check(it + 2, pos);
} else {
return check(it + 1, pos + 1) || check(it + 3, pos + 1);
}
}
int main() {
int t;
cin >> t;
while(t--) {
cin >> s >> sub;
cout << ((check(0, 0) || check(1, 0)) ? "YES" : "NO") << endl;
}
}