#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
	int t, cnt, i, j;
	char m[25002], w[25002];
	scanf("%d", &t);
	while(t--) {
		cnt=0; i=j=0;
		scanf("%s%s", m, w);
		if(strlen(m)<strlen(w)) {
			for(; i<strlen(m); i++) {
				for(; j<strlen(w); j++) {
					if(m[i]==w[j]) {
						cnt++; 
						j++;
						break;
					}	
				}
			}
			if(cnt==strlen(m)) printf("YES\n");
			else printf("NO\n");
		}
		else {
			for(; i<strlen(w); i++) {
				for(; j<strlen(m); j++) {
					if(w[i]==m[j]) {
						cnt++;
						j++;
						break;
					}
				}
			}
			if(cnt==strlen(w)) printf("YES\n");
			else printf("NO\n");
		}
	}
	return 0;}