#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING

#include <bits/stdc++.h>

using namespace std;
const int N = 5050;
char str1[N], str2[N], str3[N << 1];

int main() {
    int T;
    scanf("%d", &T);
    while (T--) {
        scanf("%s%s", str1, str2);
        *regex_replace(str3, str2, str2 + strlen(str2), regex("\\.\\*"), "(.)\\1*") = 0;
        puts(regex_match(str1, regex(str3)) ? "yes" : "no");
    }
    return 0;
}
