#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){
if(b==0)
return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
ll ans = 1;
while(pow!=0){
if(pow&1==1){
ans = ans*base;
ans = ans%mod;
}
base *= base;base%=mod;
pow/=2;
}return ans;
}
ll inv(ll x){
return expo(x,mod-2);
}
double pi = 3.141592653589793238462643;
double error = 0.0000001;
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1}; // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/* -------Template ends here-------- */
const int M = 100001;
int dp[2222][2222];
void reset(){
memset(dp , -1 , sizeof(dp));
}
bool isA(char ex){
if(ex >= 'A' && ex <='Z') return 1;
if(ex >= 'a' && ex <='z') return 1;
return 0;
}
string dofor(string str , int yu){
string here = "";
for(int i = 0 ; i<str.length() ; i++){
if(isA(str[i])){
here += str[i];
}
else{
for(int j = 0 ; j<4 ; j++){
here += '*';
}
}
}
return here;
}
int n , m;
string a , b;
int vv(int i, int j){
if(i == n && j == m) return true;
if(i == n){
for(int k = j ; k < m ; k++){
if(b[k] != '*') return false;
}
return true;
}
if(j == m){
for(int k = i ; k < n ; k++){
if(a[k] != '*') return false;
}
return true;
}
int &res = dp[i][j];
if(res == -1){
res = 0;
if(a[i] != '*' && b[j] != '*'){
if(a[i] == b[j]) res = vv(i + 1, j + 1);
else res = false;
}
else{
if(a[i] != '*' && b[j] == '*') res = vv(i, j + 1) || vv(i + 1, j + 1);
else if(a[i] == '*' && b[j] != '*') res = vv(i + 1, j) || vv(i + 1, j + 1);
else res = res || vv(i + 1, j + 1) || vv(i + 1, j) || vv(i, j + 1);
}
}
return res;
}
int main(){
freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
int T;
si(T);
for(int alp = 1 ; alp <= T ; alp++){
string ans;
reset();
string s1 , s2;
cin >> s1 >> s2;
a = dofor(s1 , 0);
b = dofor(s2 , 1);
n = a.length();
m = b.length();
if(vv(0 , 0) == 1){
ans = "TRUE";
}
else{
ans = "FALSE";
}
printf("Case #%d: " , alp);
cout<<ans<<"\n";
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgdWxsIHVuc2lnbmVkIGxvbmcgbG9uZwojZGVmaW5lIHNpKFgpIHNjYW5mKCIlZCIsICYoWCkpCiNkZWZpbmUgc2xsKFgpIHNjYW5mKCIlbGxkIiwmKFgpKQojZGVmaW5lIElORkwgMHgzZjNmM2YzZjNmM2YzZjNmTEwKY29uc3QgaW50IG1vZCA9IDFlOSs3OwpsbCBnY2QobGwgYSxsbCBiKXsKCWlmKGI9PTApCglyZXR1cm4gYTtyZXR1cm4gZ2NkKGIsYSViKTsKfQpsbCBleHBvKGxsIGJhc2UsbGwgcG93KXsKICAgIGxsIGFucyA9IDE7CiAgICB3aGlsZShwb3chPTApewogICAgICAgIGlmKHBvdyYxPT0xKXsKICAgICAgICAgICAgYW5zID0gYW5zKmJhc2U7CiAgICAgICAgICAgIGFucyA9IGFucyVtb2Q7CiAgICAgICAgfQogICAgICAgIGJhc2UgKj0gYmFzZTtiYXNlJT1tb2Q7CiAgICAgICAgcG93Lz0yOwogICAgfXJldHVybiBhbnM7Cn0KbGwgaW52KGxsIHgpewogICAgcmV0dXJuIGV4cG8oeCxtb2QtMik7Cn0KCmRvdWJsZSBwaSA9IDMuMTQxNTkyNjUzNTg5NzkzMjM4NDYyNjQzOwpkb3VibGUgZXJyb3IgPSAwLjAwMDAwMDE7CmludCBkeFs4XSA9IHsxICwgMCAsIC0xICwgMCAsIDEgLCAtMSAsIC0xICwgMX07ICAgIC8vIGxhc3QgNCBkaWFnb25hbAppbnQgZHlbOF0gPSB7MCAsIDEgLCAwICwgLTEgLCAxICwgMSAsIC0xICwgLTF9OwovKiAtLS0tLS0tVGVtcGxhdGUgZW5kcyBoZXJlLS0tLS0tLS0gKi8KCmNvbnN0IGludCBNID0gMTAwMDAxOwoKaW50IGRwWzIyMjJdWzIyMjJdOwoKCnZvaWQgcmVzZXQoKXsKICAgIG1lbXNldChkcCAsIC0xICwgc2l6ZW9mKGRwKSk7Cn0KCmJvb2wgaXNBKGNoYXIgZXgpewogICAgaWYoZXggPj0gJ0EnICYmIGV4IDw9J1onKSByZXR1cm4gMTsKICAgIGlmKGV4ID49ICdhJyAmJiBleCA8PSd6JykgcmV0dXJuIDE7CiAgICByZXR1cm4gMDsKfQoKc3RyaW5nIGRvZm9yKHN0cmluZyBzdHIgLCBpbnQgeXUpewogICAgc3RyaW5nIGhlcmUgPSAiIjsKICAgIGZvcihpbnQgaSA9IDAgOyBpPHN0ci5sZW5ndGgoKSA7IGkrKyl7CiAgICAgICAgaWYoaXNBKHN0cltpXSkpewogICAgICAgICAgICBoZXJlICs9IHN0cltpXTsKICAgICAgICB9CiAgICAgICAgZWxzZXsKICAgICAgICAgICAgZm9yKGludCBqID0gMCA7IGo8NCA7IGorKyl7CiAgICAgICAgICAgICAgICBoZXJlICs9ICcqJzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHJldHVybiBoZXJlOwp9CmludCBuICwgbTsKc3RyaW5nIGEgLCBiOwppbnQgdnYoaW50IGksIGludCBqKXsKICAgIGlmKGkgPT0gbiAmJiBqID09IG0pIHJldHVybiB0cnVlOwogICAgaWYoaSA9PSBuKXsKICAgICAgICBmb3IoaW50IGsgPSBqIDsgayA8IG0gOyBrKyspewogICAgICAgICAgICBpZihiW2tdICE9ICcqJykgcmV0dXJuIGZhbHNlOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KICAgIGlmKGogPT0gbSl7CiAgICAgICAgZm9yKGludCBrID0gaSA7IGsgPCBuIDsgaysrKXsKICAgICAgICAgICAgaWYoYVtrXSAhPSAnKicpIHJldHVybiBmYWxzZTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHRydWU7CiAgICB9CgogICAgaW50ICZyZXMgPSBkcFtpXVtqXTsKICAgIGlmKHJlcyA9PSAtMSl7CiAgICAgICAgcmVzID0gMDsKICAgICAgICBpZihhW2ldICE9ICcqJyAmJiBiW2pdICE9ICcqJyl7CiAgICAgICAgICAgIGlmKGFbaV0gPT0gYltqXSkgcmVzID0gdnYoaSArIDEsIGogKyAxKTsKICAgICAgICAgICAgZWxzZSByZXMgPSBmYWxzZTsKICAgICAgICB9CiAgICAgICAgZWxzZXsKICAgICAgICAgICAgaWYoYVtpXSAhPSAnKicgJiYgYltqXSA9PSAnKicpIHJlcyA9IHZ2KGksIGogKyAxKSB8fCB2dihpICsgMSwgaiArIDEpOwogICAgICAgICAgICBlbHNlIGlmKGFbaV0gPT0gJyonICYmIGJbal0gIT0gJyonKSByZXMgPSB2dihpICsgMSwgaikgfHwgdnYoaSArIDEsIGogKyAxKTsKICAgICAgICAgICAgZWxzZSByZXMgPSByZXMgfHwgdnYoaSArIDEsIGogKyAxKSB8fCB2dihpICsgMSwgaikgfHwgdnYoaSwgaiArIDEpOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiByZXM7Cn0KaW50IG1haW4oKXsKICAgIGZyZW9wZW4oImlucHV0LnR4dCIsICJydCIsIHN0ZGluKTsKICAgIGZyZW9wZW4oIm91dHB1dC50eHQiLCAid3QiLCBzdGRvdXQpOwoKICAgIGludCBUOwogICAgc2koVCk7CgogICAgZm9yKGludCBhbHAgPSAxIDsgYWxwIDw9IFQgOyBhbHArKyl7CiAgICAgICAgc3RyaW5nIGFuczsKICAgICAgICByZXNldCgpOwoKICAgICAgICBzdHJpbmcgczEgLCBzMjsKCiAgICAgICAgY2luID4+IHMxID4+IHMyOwoKICAgICAgICBhID0gZG9mb3IoczEgLCAwKTsKICAgICAgICBiID0gZG9mb3IoczIgLCAxKTsKCiAgICAgICAgbiA9IGEubGVuZ3RoKCk7CiAgICAgICAgbSA9IGIubGVuZ3RoKCk7CgogICAgICAgIGlmKHZ2KDAgLCAwKSA9PSAxKXsKICAgICAgICAgICAgYW5zID0gIlRSVUUiOwogICAgICAgIH0KICAgICAgICBlbHNlewogICAgICAgICAgICBhbnMgPSAiRkFMU0UiOwogICAgICAgIH0KCgoKCgoKCgoKCgoKCgoKCgogICAgICAgIHByaW50ZigiQ2FzZSAjJWQ6ICIgLCBhbHApOwogICAgICAgIGNvdXQ8PGFuczw8IlxuIjsKCiAgICB9CgoKCgoKCgoKCgoKCgoKCgoKCgoKfQoKCgo=