2565_1_Quiz_2_2

Max Score = 100


6531332121
# 1661888, 2022-10-29 09:40:07, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True


exec(input())

# 1661911, 2022-10-29 09:40:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word == word:
        return True
    return True


exec(input())

# 1662132, 2022-10-29 09:48:27, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        return True
        # for index in range(len(word)):
        #     if pattern[index] == '?':


exec(input())

# 1662247, 2022-10-29 09:51:43, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] not in exclude_chars:
                    return False
                else:
                    pass
            else:
                if pattern[index] == word[index]:
                    pass
                else:
                    return False
        return True


exec(input())

# 1662271, 2022-10-29 09:52:29, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
                else:
                    pass
            else:
                if pattern[index] == word[index]:
                    pass
                else:
                    return False
        return True


exec(input())

# 1662364, 2022-10-29 09:55:42, --x-x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
            else:
                if pattern[index] == word[index]:
                    pass
                else:
                    return False
                if word[index] in include_chars:
                    include_chars.remove(word[index])
                    pass
                else:
                    return False
        return True


exec(input())

# 1662373, 2022-10-29 09:56:06, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
            else:
                if pattern[index] == word[index]:
                    pass
                else:
                    return False
                # if word[index] in include_chars:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        return True


exec(input())

# 1662492, 2022-10-29 09:59:25, --x-x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
            else:
                if pattern[index] == word[index]:
                    pass
                else:
                    return False
                if word[index] in include:
                    include_chars.remove(word[index])
                    pass
                else:
                    return False
        return True


exec(input())

# 1662561, 2022-10-29 10:01:56, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
            else:
                if pattern[index] == word[index]:
                    pass
                else:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        words = []
        for c in word:
            words.append(c)
        for c in include:
            if c in words:
                words.remove(c)
            else:
                return False

        return True


exec(input())

# 1662644, 2022-10-29 10:04:30, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        words = []
        for c in word:
            words.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
            else:
                if pattern[index] != word[index]:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
                for c in include:
                    if c in words:
                        words.remove(c)
                    else:
                        return False
        # words = []
        # for c in word:
        #     words.append(c)
        for c in include:
            if c in words:
                words.remove(c)
            else:
                return False

        return True


exec(input())

# 1662651, 2022-10-29 10:04:47, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        words = []
        for c in word:
            words.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
            else:
                if pattern[index] != word[index]:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
                for c in include:
                    if c in words:
                        words.remove(c)
                    else:
                        return False
        # words = []
        # for c in word:
        #     words.append(c)
        # for c in include:
        #     if c in words:
        #         words.remove(c)
        #     else:
        #         return False

        return True


exec(input())

# 1662687, 2022-10-29 10:05:44, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        words = []
        for c in word:
            words.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
                for c in include:
                    if c in words:
                        words.remove(c)
                    else:
                        return False
            else:
                if pattern[index] != word[index]:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        # words = []
        # for c in word:
        #     words.append(c)
        # for c in include:
        #     if c in words:
        #         words.remove(c)
        #     else:
        #         return False

        return True


exec(input())

# 1662764, 2022-10-29 10:08:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        words = []
        for c in word:
            words.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
                # for c in include:
                #     if c in words:
                #         words.remove(c)
                #     else:
                #         return False
                if word[index] in include:
                    include.remove(word[index])
                else:
                    return False
            else:
                if pattern[index] != word[index]:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        # words = []
        # for c in word:
        #     words.append(c)
        # for c in include:
        #     if c in words:
        #         words.remove(c)
        #     else:
        #         return False
        if len(include) != 0:
            return False
        return True


exec(input())

# 1662802, 2022-10-29 10:09:11, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        words = []
        for c in word:
            words.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
                # if word[index] in include:
                #     include.remove(word[index])
                # else:
                #     return False
            else:
                if pattern[index] != word[index]:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        # words = []
        # for c in word:
        #     words.append(c)
        # for c in include:
        #     if c in words:
        #         words.remove(c)
        #     else:
        #         return False
        if len(include) != 0:
            return False
        return True


exec(input())

# 1662913, 2022-10-29 10:12:28, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        words = []
        for c in word:
            words.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
                if word[index] in include:
                    include.remove(word[index])
                else:
                    return False
            else:
                if pattern[index] != word[index]:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        # for c in include:
        #     if c in words:
        #         words.remove(c)
        #     else:
        #         return False
        if len(include) != 0:
            return False
        return True


exec(input())

# 1662935, 2022-10-29 10:12:57, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
            else:
                if pattern[index] == word[index]:
                    pass
                else:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        words = []
        for c in word:
            words.append(c)
        for c in include:
            if c in words:
                words.remove(c)
            else:
                return False

        return True


exec(input())


# 1663071, 2022-10-29 10:16:05, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        words = []
        for c in word:
            words.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
                # if word[index] in include:
                #     include.remove(word[index])
                # else:
                #     return False
                for c in include:
                    if c == word[index]:
                        include.remove(word[index])
                        break
                    else:
                        return False
            else:
                if pattern[index] != word[index]:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        # for c in include:
        #     if c in words:
        #         words.remove(c)
        #     else:
        #         return False
        if len(include) != 0:
            return False
        return True


exec(input())

# 1663104, 2022-10-29 10:16:56, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        include = []
        for c in include_chars:
            include.append(c)
        words = []
        for c in word:
            words.append(c)
        for index in range(len(word)):
            if pattern[index] == '?':
                if word[index] in exclude_chars:
                    return False
                # if word[index] in include:
                #     include.remove(word[index])
                # else:
                #     return False
                for c in include:
                    if c == word[index]:
                        include.remove(word[index])
                        break
            else:
                if pattern[index] != word[index]:
                    return False
                # if word[index] in include:
                #     include_chars.remove(word[index])
                #     pass
                # else:
                #     return False
        # for c in include:
        #     if c in words:
        #         words.remove(c)
        #     else:
        #         return False
        if len(include) != 0:
            return False
        return True


exec(input())


6532040021
# 1661711, 2022-10-29 09:33:06, xxxxx (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    y = True
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            y = False
            break;
    if(not y): return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        if t.count(t[i]) != include_chars.count(t[i]):
            return False
exec(input()) 
# 1661731, 2022-10-29 09:34:14, ----- (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    y = True
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            y = False
            break;
    if(not y): return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    # t = []
    # for i in range(len(word)):
    #     if(pattern[i] == "?"):
    #         t.append(word[i]) 
    # for i in t:
    #     if t.count(t[i]) != include_chars.count(t[i]):
    #         return False
exec(input())
# 1661746, 2022-10-29 09:34:59, ----- (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    y = True
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            y = False
            break;
    if(not y): return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        if t.count(i) != include_chars.count(i):
            return False
exec(input()) 
# 1661766, 2022-10-29 09:35:50, ----- (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    y = True
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            y = False
            break;
    if(not y): return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        if t.count(i) != include_chars.count(i):
            return False
    return True
exec(input())
# 1661792, 2022-10-29 09:37:04, ----- (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    y = True
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            return False
    
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        if t.count(i) != include_chars.count(i):
            return False
    return True
exec(input()) 
# 1661856, 2022-10-29 09:39:14, ----- (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    y = True
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            return False
    
    
    # for i in range(len(word)):
    #     if pattern[i] == "?":
    #         if(word[i] in exclude_chars):
    #             return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        if t.count(i) != include_chars.count(i):
            return False
    return True
exec(input())
# 1661969, 2022-10-29 09:43:01, ----- (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern): return False
    
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        if t.count(i) != include_chars.count(i):
            return False
    return True
exec(input()) 
# 1662010, 2022-10-29 09:44:23, P--P- (40%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern): return False
    
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        if t.count(i) != include_chars.count(i) and include_chars != "":
            return False
    return True
exec(input()) 
# 1662049, 2022-10-29 09:45:32, P--P- (40%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern): return False
    
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        if t.count(i) < include_chars.count(i):
            return False
    return True
exec(input()) 
# 1662136, 2022-10-29 09:48:34, ----- (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern): return False
    
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        print(i, t.count(i))
        if t.count(i) < include_chars.count(i):
            return False
        if include_chars.count(i) not in t:
            return False
    return True
exec(input()) 
# 1662160, 2022-10-29 09:49:20, ----- (0%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern): return False
    
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in t:
        # print(i, t.count(i))
        if t.count(i) < include_chars.count(i):
            return False
        if include_chars.count(i) not in t:
            return False
    return True
exec(input())
# 1662241, 2022-10-29 09:51:37, PPPPP (100%)

def cmp(a, b):
    if(a != b and b != "?"):return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern): return False
    
    for i in range(len(word)):
        if not cmp(word[i], pattern[i]):
            return False
    
    for i in range(len(word)):
        if pattern[i] == "?":
            if(word[i] in exclude_chars):
                return False
    t = []
    for i in range(len(word)):
        if(pattern[i] == "?"):
            t.append(word[i]) 
    for i in include_chars:
        if(i not in t):return False
    for i in t:
        # print(i, t.count(i))
        if t.count(i) < include_chars.count(i):
            return False
    return True
exec(input()) 

6531318421
# 1661774, 2022-10-29 09:36:02, ----- (0%)

from xml.etree.ElementInclude import include


def match(word, pattern, include_chars, exclude_chars):
    l = len(include_chars)
    ind = 0
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            elif word[i] in include_chars:
                ind += 1

    if ind == len(include_chars):
        return True
    else:
        return False


# exec(input())  # DON'T remove this line
print(match("MACMA", "M?C??", "AM", ""))

# 1661783, 2022-10-29 09:36:18, PP-P- (60%)

from xml.etree.ElementInclude import include


def match(word, pattern, include_chars, exclude_chars):
    l = len(include_chars)
    ind = 0
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            elif word[i] in include_chars:
                ind += 1

    if ind == len(include_chars):
        return True
    else:
        return False


exec(input())  # DON'T remove this line
# print(match("MACMA", "M?C??", "AM", ""))
# 1662080, 2022-10-29 09:46:40, ----- (0%)

from xml.etree.ElementInclude import include


def match(word, pattern, include_chars, exclude_chars):
    l = len(include_chars)
    ind = 0
    check = ''
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            check += word[i]
    return check == include_chars


exec(input())  # DON'T remove this line
# print(match("MACMA", "M?C??", "MAX", ""))

# 1662219, 2022-10-29 09:50:55, PP-P- (60%)

from xml.etree.ElementInclude import include


def match(word, pattern, include_chars, exclude_chars):
    l = len(include_chars)
    ind = 0
    check = ''
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            check += word[i]
    # return check == include_chars
    for x in include_chars:
        if x not in check:
            return False
    return True


exec(input())  # DON'T remove this line
# print(match("MACMA", "M?CMA", "", "MACMA"))

# 1662324, 2022-10-29 09:54:24, ----- (0%)

from xml.etree.ElementInclude import include


def match(word, pattern, include_chars, exclude_chars):
    l = len(include_chars)
    ind = 0
    check = ''
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            check += word[i]
    # return check == include_chars
    check = list(check).sort()
    inlucde_char = list(include_chars).sort()
    for i in range(len(include_chars)):
        if include_chars[i] != check:
            return False
    return True
    # for x in include_chars:
    #     if x not in check:
    #         return False
    # return True


# exec(input())  # DON'T remove this line
print(match("MACMA", "M?C??", "AAA", ""))

# 1662330, 2022-10-29 09:54:37, P--P- (40%)

from xml.etree.ElementInclude import include


def match(word, pattern, include_chars, exclude_chars):
    l = len(include_chars)
    ind = 0
    check = ''
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            check += word[i]
    # return check == include_chars
    check = list(check).sort()
    inlucde_char = list(include_chars).sort()
    for i in range(len(include_chars)):
        if include_chars[i] != check:
            return False
    return True
    # for x in include_chars:
    #     if x not in check:
    #         return False
    # return True


exec(input())  # DON'T remove this line
# print(match("MACMA", "M?C??", "AAA", ""))
# 1662375, 2022-10-29 09:56:16, P-PP- (60%)

from xml.etree.ElementInclude import include


def match(word, pattern, include_chars, exclude_chars):
    l = len(include_chars)
    ind = 0
    check = ''
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            check += word[i]
    # return check == include_chars
    check = list(check)
    include_chars = list(include_chars)
    check.sort()
    include_chars.sort()
    # print(check)
    # print(inclu)
    for i in range(len(include_chars)):
        if include_chars[i] != check[i]:
            return False
    return True
    # for x in include_chars:
    #     if x not in check:
    #         return False
    # return True


exec(input())  # DON'T remove this line
# print(match("MACMA", "M?C??", "AAA", ""))

# 1663958, 2022-10-29 10:34:23, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    ind = 0
    check = ''
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            check += word[i]
    # return check == include_chars
    check = list(check)
    include_chars = list(include_chars)
    check.sort()
    include_chars.sort()
    # print(check)
    # print(inclu)
    i = 0
    j = 0
    cnt = 0
    while j < len(include_chars) and i < len(check):
        if include_chars[j] == check[i]:
            j += 1
            i += 1
            cnt += 1
        else:
            i += 1
    if cnt == len(include_chars):
        return True
    else:
        return False
    # for i in range(len(include_chars)):
    #     if include_chars[i] != check[i]:
    #         return False
    # return True
    # for x in include_chars:
    #     if x not in check:
    #         return False
    # return True


# exec(input())  # DON'T remove this line
print(match("MACMA", "M?C??", "", "CPE"))


# AAM
# AAA

# AM
# AMA

# 1663967, 2022-10-29 10:34:36, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    ind = 0
    check = ''
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            check += word[i]
    # return check == include_chars
    check = list(check)
    include_chars = list(include_chars)
    check.sort()
    include_chars.sort()
    # print(check)
    # print(inclu)
    i = 0
    j = 0
    cnt = 0
    while j < len(include_chars) and i < len(check):
        if include_chars[j] == check[i]:
            j += 1
            i += 1
            cnt += 1
        else:
            i += 1
    if cnt == len(include_chars):
        return True
    else:
        return False
    # for i in range(len(include_chars)):
    #     if include_chars[i] != check[i]:
    #         return False
    # return True
    # for x in include_chars:
    #     if x not in check:
    #         return False
    # return True


exec(input())  # DON'T remove this line
# print(match("MACMA", "M?C??", "", "CPE"))


# AAM
# AAA

# AM
# AMA

6531347621
# 1662486, 2022-10-29 09:59:19, ----- (0%)

def chardict(t):
    dictout = {}
    for e in t:
        if e not in dictout:
            dictout[e] = 1
        else:
            dictout[e] += 1
    return dictout

def check_include_chars(word,include_chars):
    include_chars_count = chardict(include_chars)
    for ch in word:
        if ch in include_chars_count:
            include_chars_count[ch] -= 1
    for char in include_chars_count:
        if include_chars_count[char] > 0:
            return False
    return True

def checklen(word,pattern):
    return len(word) == len(pattern)

def checklen_and_char(word,pattern):
    if not checklen(word,pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            continue
        elif pattern[i] == word[i]:
            continue
        else:
            return False
    return True

def checkexclde(word,pattern,exclude_chars):
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for e in word:
        if word[i] in exclude_chars:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    result = checklen_and_char(word,pattern) and checkexclde(word,pattern,exclude_chars) and check_include_chars(word,include_chars)
    print(result)



exec(input())

# 1662509, 2022-10-29 10:00:04, ----- (0%)

def chardict(t):
    dictout = {}
    for e in t:
        if e not in dictout:
            dictout[e] = 1
        else:
            dictout[e] += 1
    return dictout

def check_include_chars(word,include_chars):
    include_chars_count = chardict(include_chars)
    for ch in word:
        if ch in include_chars_count:
            include_chars_count[ch] -= 1
    for char in include_chars_count:
        if include_chars_count[char] > 0:
            return False
    return True

def checklen(word,pattern):
    return len(word) == len(pattern)

def checklen_and_char(word,pattern):
    if not checklen(word,pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            continue
        elif pattern[i] == word[i]:
            continue
        else:
            return False
    return True

def checkexclde(word,pattern,exclude_chars):
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for e in word:
        if word[i] in exclude_chars:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    result = checklen_and_char(word,pattern) and checkexclde(word,pattern,exclude_chars) and check_include_chars(word,include_chars)
    print(result)
    return


exec(input())

# 1662599, 2022-10-29 10:03:01, xxxxx (0%)

def chardict(t):
    dictout = {}
    for e in t:
        if e not in dictout:
            dictout[e] = 1
        else:
            dictout[e] += 1
    return dictout

def check_include_chars(word,include_chars):
    include_chars_count = chardict(include_chars)
    for ch in word:
        if ch in include_chars_count:
            include_chars_count[ch] -= 1
    for char in include_chars_count:
        if include_chars_count[char] > 0:
            return False
    return True

def checklen(word,pattern):
    return len(word) == len(pattern)

def checklen_and_char(word,pattern):
    if not checklen(word,pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            continue
        elif pattern[i] == word[i]:
            continue
        else:
            return False
    return True

def checkexclude(word,pattern,exclude_chars):
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in exclude_chars:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    result = checklen_and_char(word,pattern) and checkexclude(word,pattern,exclude_chars) and check_include_chars(word,include_chars)
    print(result)
    return

for i in range(10):
    exec(input())

# 1662611, 2022-10-29 10:03:16, ----- (0%)

def chardict(t):
    dictout = {}
    for e in t:
        if e not in dictout:
            dictout[e] = 1
        else:
            dictout[e] += 1
    return dictout

def check_include_chars(word,include_chars):
    include_chars_count = chardict(include_chars)
    for ch in word:
        if ch in include_chars_count:
            include_chars_count[ch] -= 1
    for char in include_chars_count:
        if include_chars_count[char] > 0:
            return False
    return True

def checklen(word,pattern):
    return len(word) == len(pattern)

def checklen_and_char(word,pattern):
    if not checklen(word,pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            continue
        elif pattern[i] == word[i]:
            continue
        else:
            return False
    return True

def checkexclude(word,pattern,exclude_chars):
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in exclude_chars:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    result = checklen_and_char(word,pattern) and checkexclude(word,pattern,exclude_chars) and check_include_chars(word,include_chars)
    print(result)
    return


exec(input())

# 1662625, 2022-10-29 10:03:49, PP-P- (60%)

def chardict(t):
    dictout = {}
    for e in t:
        if e not in dictout:
            dictout[e] = 1
        else:
            dictout[e] += 1
    return dictout

def check_include_chars(word,include_chars):
    include_chars_count = chardict(include_chars)
    for ch in word:
        if ch in include_chars_count:
            include_chars_count[ch] -= 1
    for char in include_chars_count:
        if include_chars_count[char] > 0:
            return False
    return True

def checklen(word,pattern):
    return len(word) == len(pattern)

def checklen_and_char(word,pattern):
    if not checklen(word,pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            continue
        elif pattern[i] == word[i]:
            continue
        else:
            return False
    return True

def checkexclude(word,pattern,exclude_chars):
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in exclude_chars:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    result = checklen_and_char(word,pattern) and checkexclude(word,pattern,exclude_chars) and check_include_chars(word,include_chars)
    return result

exec(input())
# 1662830, 2022-10-29 10:09:54, ----- (0%)

def chardict(t):
    dictout = {}
    for e in t:
        if e not in dictout:
            dictout[e] = 1
        else:
            dictout[e] += 1
    return dictout

def check_include_chars(word,pattern,include_chars):
    include_chars_count = chardict(include_chars)
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in include_chars_count:
            include_chars_count[word[ind]] -= 1
    for key in include_chars_count:
        if include_chars_count[key] > 0:
            return False
    return True

def checklen(word,pattern):
    return len(word) == len(pattern)

def checklen_and_char(word,pattern):
    if not checklen(word,pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            continue
        elif pattern[i] == word[i]:
            continue
        else:
            return False
    return True

def checkexclude(word,pattern,exclude_chars):
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in exclude_chars:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    result = checklen_and_char(word,pattern) and checkexclude(word,pattern,exclude_chars) and check_include_chars(word,pattern,include_chars)
    print(result)
    return result


exec(input())

# 1662834, 2022-10-29 10:10:07, PPPPP (100%)

def chardict(t):
    dictout = {}
    for e in t:
        if e not in dictout:
            dictout[e] = 1
        else:
            dictout[e] += 1
    return dictout

def check_include_chars(word,pattern,include_chars):
    include_chars_count = chardict(include_chars)
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in include_chars_count:
            include_chars_count[word[ind]] -= 1
    for key in include_chars_count:
        if include_chars_count[key] > 0:
            return False
    return True

def checklen(word,pattern):
    return len(word) == len(pattern)

def checklen_and_char(word,pattern):
    if not checklen(word,pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            continue
        elif pattern[i] == word[i]:
            continue
        else:
            return False
    return True

def checkexclude(word,pattern,exclude_chars):
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in exclude_chars:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    result = checklen_and_char(word,pattern) and checkexclude(word,pattern,exclude_chars) and check_include_chars(word,pattern,include_chars)
    return result


exec(input())

# 1663017, 2022-10-29 10:15:01, PPPPP (100%)

def chardict(t):
    dictout = {}
    for e in t:
        if e not in dictout:
            dictout[e] = 1
        else:
            dictout[e] += 1
    return dictout

def check_include_chars(word,pattern,include_chars):
    include_chars_count = chardict(include_chars)
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in include_chars_count:
            include_chars_count[word[ind]] -= 1
    for key in include_chars_count:
        if include_chars_count[key] > 0:
            return False
    return True

def checklen(word,pattern):
    return len(word) == len(pattern)

def checklen_and_char(word,pattern):
    if not checklen(word,pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            continue
        elif pattern[i] == word[i]:
            continue
        else:
            return False
    return True

def checkexclude(word,pattern,exclude_chars):
    indexofq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            indexofq.append(i)
    for ind in indexofq:
        if word[ind] in exclude_chars:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    result = checklen_and_char(word,pattern) and checkexclude(word,pattern,exclude_chars) and check_include_chars(word,pattern,include_chars)
    return result
    
exec(input())

6532180221
# 1661572, 2022-10-29 09:28:25, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
 vst=[0]*99
 for i in include_chars:vst[ord(i)]+=1
 if(len(word)!=len(pattern)):return False
 for i in range(len(word)):
  if(pattern[i]=='?'and word[i]in exclude_chars):return False
  if(pattern[i]!=word[i] and pattern[i]!='?'):return False
  if(pattern[i]=='?'):vst[word[i]]-=1
 for i in vst:
  if(i==0):continue
  else:return False
 return True
     
exec(input())
# 1661617, 2022-10-29 09:29:37, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 vst=[0]*99
 for i in include_chars:vst[ord(i)]+=1
 if(len(word)!=len(pattern)):return False
 for i in range(len(word)):
  if(pattern[i]=='?'and word[i]in exclude_chars):return False
  if(pattern[i]!=word[i] and pattern[i]!='?'):return False
  if(pattern[i]=='?'):vst[ord(word[i])]-=1
 for i in vst:
  if(i==0):continue
  else:return False
 return True
     
exec(input())
# 1661646, 2022-10-29 09:30:38, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 vst=[0]*99
 for i in include_chars:vst[ord(i)]+=1
 if(len(word)!=len(pattern)):return False
 for i in range(len(word)):
  if(pattern[i]=='?'and word[i]in exclude_chars):return False
  if(pattern[i]!=word[i] and pattern[i]!='?'):return False
  if(pattern[i]=='?'):vst[ord(word[i])]-=1
 for i in vst:
  if(i==0):continue
  else:return False
 return True
     
exec(input())
# 1661659, 2022-10-29 09:30:57, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 vst=[0]*199
 for i in include_chars:vst[ord(i)]+=1
 if(len(word)!=len(pattern)):return False
 for i in range(len(word)):
  if(pattern[i]=='?'and word[i]in exclude_chars):return False
  if(pattern[i]!=word[i] and pattern[i]!='?'):return False
  if(pattern[i]=='?'):vst[ord(word[i])]-=1
 for i in vst:
  if(i==0):continue
  else:return False
 return True
     
exec(input())
# 1661762, 2022-10-29 09:35:45, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 vst=[0]*199;f=0
 for i in include_chars:vst[ord(i)]+=1
 if(len(word)!=len(pattern)):return False
 for i in range(len(word)):
  if(pattern[i]=='?'and word[i]in exclude_chars):f=1
  if(pattern[i]!=word[i] and pattern[i]!='?'):f=1
  if(pattern[i]=='?'):vst[ord(word[i])]-=1
 for i in vst:
  if(i!=0):f=1
 
 if(f):return False
 return True
     
exec(input())
# 1661919, 2022-10-29 09:41:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    vst = [0]*199
    for i in include_chars:
        vst[ord(i)] += 1
    if(len(word) != len(pattern)):
        return False

    for i in range(len(word)):
        if(pattern[i]=='?'):
            if(word[i] in exclude_chars): return False
            vst[ord(word[i])] -= 1
        else:
            if(word[i] != pattern[i]): return False
    
    for i in vst:
        if(i != 0): return False
    return True
     
exec(input())
# 1661925, 2022-10-29 09:41:22, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    vst = [0]*199
    for i in include_chars:
        vst[ord(i)] += 1
    if(len(word) != len(pattern)):
        return False

    for i in range(len(word)):
        if(pattern[i]=='?'):
            if(word[i] in exclude_chars): return False
            vst[ord(word[i])] -= 1
        else:
            if(word[i] != pattern[i]): return False
    
    for i in vst:
        if(i != 0): return False
    return True
     
exec(input()) # DON'T remove this line
# 1661995, 2022-10-29 09:43:51, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    vst = [0]*199
    for i in include_chars:
        vst[ord(i)] += 1
    if(len(word) != len(pattern)):
        return False

    for i in range(len(word)):
        if(pattern[i]=='?'):
            if(word[i] in exclude_chars): return False
            vst[ord(word[i])] -= 1
        else:
            if(word[i] != pattern[i]): return False
    
    for i in vst:
        if(i > 0): return False
    return True
     
exec(input()) # DON'T remove this line

6431804021
# 1662041, 2022-10-29 09:45:22, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    
    if len(word) != len(pattern) :
        x = False
        
    for e in range(len(word)) :
        if word[e] != pattern[e] or word[e] != '?' :
            x = False ; break
            
        if word[e] == '?' and word[e] in exclude_chars :
            x = False ; break
exec(input())
# 1662054, 2022-10-29 09:45:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    
    if len(word) != len(pattern) :
        x = False
        
    for e in range(len(word)) :
        if word[e] != pattern[e] or word[e] != '?' :
            x = False ; break
            
        if word[e] == '?' and word[e] in exclude_chars :
            x = False ; break
    return x
exec(input())
# 1662720, 2022-10-29 10:06:44, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    
    if len(word) != len(pattern) :
        x = False
        
    for e in range(len(word)) :
        if pattern[e] != '?' :
            if word[e] != pattern[e] :
                x = False
            
        if pattern[e] == '?' and word[e] in exclude_chars :
            x = False ; break
            
        
    return x



exec(input()) 
# 1662785, 2022-10-29 10:08:47, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    
    if len(word) != len(pattern) :
        return False
        
    for e in range(len(word)) :
        if pattern[e] != '?' :
            if word[e] != pattern[e] :
                x = False
            
        if pattern[e] == '?' and word[e] in exclude_chars :
            x = False ; break
            
    #for i in range(len(
    return x



exec(input()) 
# 1663016, 2022-10-29 10:14:59, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    z = []
    
    if len(word) != len(pattern) :
        return False
        
    for e in range(len(word)) :
        if pattern[e] != '?' :
            if word[e] != pattern[e] :
                x = False
        z.append(word[e])
            
        if pattern[e] == '?' and word[e] in exclude_chars :
            x = False ; break
            
    for i in range(len(include_chars)):
        if include_chars[i] not in z :
            x = False ; break
    
    return x



exec(input()) 
# 1663174, 2022-10-29 10:18:54, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    z = []
    
    if len(word) != len(pattern) :
        return False
        
    for e in range(len(word)) :
        if pattern[e] != '?' :
            if word[e] != pattern[e] :
                x = False
        z.append(word[e])
            
        if pattern[e] == '?' and word[e] in exclude_chars :
            x = False ; break
            
    for i in range(len(include_chars)):
        if include_chars[i] not in z :
            x = False ; break
        z.remove(include_chars[i])
    
    return x



exec(input()) 
# 1663277, 2022-10-29 10:21:26, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    z = []
    
    if len(word) != len(pattern) :
        return False
        
    for e in range(len(word)) :
        if pattern[e] != '?' :
            if word[e] != pattern[e] :
                x = False
        if pattern[e] == '?' :
            z.append(word[e])
            
        if pattern[e] == '?' and word[e] in exclude_chars :
            x = False ; break
            
    for i in range(len(include_chars)):
        if include_chars[i] not in z :
            x = False ; break
        z.remove(include_chars[i])
    
    return x



exec(input()) 

6530040721
# 1661827, 2022-10-29 09:38:21, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in range(len(word)):
        if pattern[e] == '?' and word[e] in exclude_chars:
            return False
    for n in exclude_chars:
        if n not in word:
            return False
    return True


exec(input()) # DON'T remove this line
# 1661975, 2022-10-29 09:43:09, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in range(len(word)):
        if pattern[e] == '?' and word[e] in exclude_chars:
            return False
    for n in include_chars:
        if n not in word:
            return False
    return True

exec(input()) # DON'T remove this line

# 1662206, 2022-10-29 09:50:31, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in range(len(word)):
        if pattern[e] == '?' and word[e] in exclude_chars:
            return False
    j = []
    for n in include_chars:
        if n not in word:
            return False
        j.append(word.index(n))
    for m in range(len(j)-1):
        z0 = j[0:m]
        z1 = j[m+1:len(j)]
        if j[m] in z0 or j[m] in z1:
            return False
    return True
exec(input()) # DON'T remove this line
# 1662264, 2022-10-29 09:52:19, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in range(len(word)):
        if pattern[e] == '?' and word[e] in exclude_chars:
            return False
    j = []
    for n in include_chars:
        if n not in word:
            return False
        if pattern(n) == '?':
            j.append(word.index(n))
    for m in range(len(j)-1):
        z0 = j[0:m]
        z1 = j[m+1:len(j)]
        if j[m] in z0 or j[m] in z1:
            return False
    return True
exec(input()) # DON'T remove this line

# 1662272, 2022-10-29 09:52:31, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in range(len(word)):
        if pattern[e] == '?' and word[e] in exclude_chars:
            return False
    j = []
    for n in include_chars:
        if n not in word:
            return False
        if pattern(n) == '?':
            j.append(word.index(n))
    for m in range(len(j)):
        z0 = j[0:m]
        z1 = j[m+1:len(j)]
        if j[m] in z0 or j[m] in z1:
            return False
    return True
exec(input()) # DON'T remove this line
# 1662445, 2022-10-29 09:58:17, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in range(len(word)):
        if pattern[e] == '?' and word[e] in exclude_chars:
            return False
    for n in include_chars:
        if n not in word:
            return False
    return True

exec(input()) # DON'T remove this line
# 1662614, 2022-10-29 10:03:18, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in range(len(word)):
        if pattern[e] == '?' and word[e] in exclude_chars:
            return False
    
    for n in include_chars:
        if n not in word:
            return False
    j = []
    for m in range(len(pattern)):
        if pattern[m] == '?':
            j.append(word[m])
    for n1 in range(len(include_chars)):
        if include_chars[n1] not in j:
            return False
        else:
            j.pop(j.index(include_chars[n1]))
    
    return True
    
exec(input()) # DON'T remove this line

6531306921
# 1662159, 2022-10-29 09:49:20, xP-Px (40%)

def  match(word, pattern, include_chars, exclude_chars):
  d=True
  for i in range(len(word)):
    if pattern[i]=='?' or pattern[i]==word[i]:
      c=1
    else:
      return False
  wordcopy=word
  for i in include_chars:
    if i in wordcopy:
      x=wordcopy.index(i)
      wordcopy=wordcopy[:x]+wordcopy[x+1:]
    else:
      return False
  wordcopy=word
  for i in exclude_chars:
    if i in wordcopy:
      return False
  return d
exec(input())
# 1662318, 2022-10-29 09:54:07, xxxxx (0%)

def  match(word, pattern, include_chars, exclude_chars):
  d=True
  charlist=[]
  for i in range(len(pattern)):
    if pattern[i]=='?':
      charlist.append(word(i))
    if pattern[i]==word[i]:
      c=1
    else:
      return False
  charlist2=charlist
  for i in include_chars:
    if i in charlist:
      x=charlist.pop(i)
    else:
      return False
  
  for i in charlist2:
    if i in exclude_chars:
      return False
  return d
exec(input())
# 1662343, 2022-10-29 09:54:59, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
  d=True
  charlist=[]
  for i in range(len(pattern)):
    if pattern[i]=='?':
      charlist.append(word[i])
    if pattern[i]==word[i]:
      c=1
    else:
      return False
  charlist2=charlist
  for i in include_chars:
    if i in charlist:
      x=charlist.pop(i)
    else:
      return False
  
  for i in charlist2:
    if i in exclude_chars:
      return False
  return d
exec(input())
# 1662590, 2022-10-29 10:02:45, x--Px (20%)

def  match(word, pattern, include_chars, exclude_chars):
  d=True
  charlist=[]
  for i in range(len(pattern)):
    if pattern[i]=='?':
      charlist.append(word[i])
    elif pattern[i]==word[i]:
      c=1
    else:
      d=False

  charlist2=charlist
  for i in range(len(include_chars)):
    if include_chars[i] in charlist:
      y=charlist.index(include_chars[i])
      x=charlist.pop(y)
      print(charlist)
    else:
      d=False
  
  for i in charlist2:
    if i in exclude_chars:
      d=False
  
  return d
exec(input())
# 1662605, 2022-10-29 10:03:11, xPPPx (60%)

def  match(word, pattern, include_chars, exclude_chars):
  d=True
  charlist=[]
  for i in range(len(pattern)):
    if pattern[i]=='?':
      charlist.append(word[i])
    elif pattern[i]==word[i]:
      c=1
    else:
      d=False

  charlist2=charlist
  for i in range(len(include_chars)):
    if include_chars[i] in charlist:
      y=charlist.index(include_chars[i])
      x=charlist.pop(y)
     
    else:
      d=False
  
  for i in charlist2:
    if i in exclude_chars:
      d=False
  
  return d
exec(input())
# 1662668, 2022-10-29 10:05:13, xPPPx (60%)

def  match(word, pattern, include_chars, exclude_chars):
  d=True
  charlist=[]
  if len(word)!=len(pattern):
    d=False
  for i in range(len(pattern)):
    if pattern[i]=='?':
      charlist.append(word[i])
    elif pattern[i]==word[i]:
      c=1
    else:
      d=False

  charlist2=charlist
  for i in range(len(include_chars)):
    if include_chars[i] in charlist:
      y=charlist.index(include_chars[i])
      x=charlist.pop(y)
      
    else:
      d=False
  
  for i in charlist2:
    if i in exclude_chars:
      d=False
 
  return d
exec(input())
# 1662711, 2022-10-29 10:06:31, PPPPP (100%)

def  match(word, pattern, include_chars, exclude_chars):
  d=True
  charlist=[]
  if len(word)!=len(pattern):
    return False
  for i in range(len(pattern)):
    if pattern[i]=='?':
      charlist.append(word[i])
    elif pattern[i]==word[i]:
      c=1
    else:
      d=False

  charlist2=charlist
  for i in range(len(include_chars)):
    if include_chars[i] in charlist:
      y=charlist.index(include_chars[i])
      x=charlist.pop(y)
      
    else:
      d=False
  
  for i in charlist2:
    if i in exclude_chars:
      d=False

  return d
exec(input())

6531307521
# 1662532, 2022-10-29 10:00:51, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    word = input()
    pattern = input()
    include_chars = input()
    exclude_chars = input()
    c = True
    if len(word) != len(pattern) :
        c = False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                c = False 
    
        elif word[i] != pattern[i] :
            c = False

    return c

exec(input()) # DON'T remove this line
# 1662618, 2022-10-29 10:03:22, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    c = True
    if len(word) != len(pattern) :
        c = False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                c = False 
    
        elif word[i] != pattern[i] :
            c = False

    return c

exec(input()) # DON'T remove this line
# 1662885, 2022-10-29 10:11:37, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    d = []
    for e in include_chars :
        d.append(e)
    c = True
    if len(word) != len(pattern) :
        c = False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                c = False 
            elif word[i] in d :
                d.remove(word[i])
                
        elif word[i] != pattern[i] :
            c = False
        if d != [] :
            c = False
    return c

exec(input()) # DON'T remove this line
# 1663064, 2022-10-29 10:15:58, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    d = []
    for e in include_chars :
        d.append(e)
    c = True
    if len(word) != len(pattern) :
        c = False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                c = False 
            elif word[i] in d :
                d.remove(word[i])
                
        elif word[i] != pattern[i] :
            c = False
    if d != [] :
        c = False
    print(c) 

exec(input()) # DON'T remove this line
# 1663083, 2022-10-29 10:16:19, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    d = []
    for e in include_chars :
        d.append(e)
    c = True
    if len(word) != len(pattern) :
        c = False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                c = False 
            elif word[i] in d :
                d.remove(word[i])
                
        elif word[i] != pattern[i] :
            c = False
        if d != [] :
            c = False
    print(c) 

exec(input()) # DON'T remove this line
# 1663189, 2022-10-29 10:19:16, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    d = []
    for e in include_chars :
        d.append(e)
    c = True
    if len(word) != len(pattern) :
        c = False
    else :
        for i in range(len(word)) :
            if pattern[i] == "?" :
                if word[i] in exclude_chars :
                    c = False 
                elif word[i] in d :
                    d.remove(word[i])
                
            elif word[i] != pattern[i] :
                c = False
        if d != [] :
            c = False
    
    print(c) 

exec(input()) # DON'T remove this line
# 1663216, 2022-10-29 10:19:46, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    d = []
    for e in include_chars :
        d.append(e)
    c = True
    if len(word) != len(pattern) :
        c = False
    else :
        for i in range(len(word)) :
            if pattern[i] == "?" :
                if word[i] in exclude_chars :
                    c = False 
                elif word[i] in d :
                    d.remove(word[i])
                
            elif word[i] != pattern[i] :
                c = False
        if d != [] :
            c = False
    
    return c 

exec(input()) # DON'T remove this line

6532125821
# 1661953, 2022-10-29 09:42:20, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word) != len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            continue
        if(pattern[i] != word[i]):
            return False
    return True
exec(input()) # DON'T remove this line
# 1662081, 2022-10-29 09:46:46, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    mark_list = []
    
    if(len(word) != len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            if(word[i] in exclude_chars):
                return False
            
            continue
        if(pattern[i] != word[i]):
            return False
    return True
exec(input()) # DON'T remove this line
# 1662099, 2022-10-29 09:47:09, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
    mark_list = []
    
    if(len(word) != len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            if(word[i] in exclude_chars):
                return False
            
            continue
        if(pattern[i] != word[i]):
            return False
    return True
exec(input()) # DON'T remove this line
# 1662102, 2022-10-29 09:47:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
    mark_list = []
    
    if(len(word) != len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            if(word[i] in exclude_chars):
                return False
            
            continue
        if(pattern[i] != word[i]):
            return False
    return True
exec(input()) # DON'T remove this line
# 1662256, 2022-10-29 09:51:54, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):

    if(len(word) != len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            if(word[i] in exclude_chars):
                return False
            include_chars.remove(word[i])
            continue
        if(pattern[i] != word[i]):
            return False
    return len(include_chars) == 0
exec(input()) # DON'T remove this line
# 1662354, 2022-10-29 09:55:22, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    include_chars_list = []
    for c in include_chars:
        include_chars_list.append(c)
    if(len(word) != len(pattern)):
        print(False)
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            if(word[i] in exclude_chars):
                print(False)
                return False
            if(word[i] in include_chars_list):
                include_chars_list.remove(word[i])
            continue
        if(pattern[i] != word[i]):
            print(False)
            return False
    print(len(include_chars_list) == 0)
    return True

exec(input()) # DON'T remove this line
# 1662365, 2022-10-29 09:55:45, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    include_chars_list = []
    for c in include_chars:
        include_chars_list.append(c)
    if(len(word) != len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            if(word[i] in exclude_chars):
                return False
            if(word[i] in include_chars_list):
                include_chars_list.remove(word[i])
            continue
        if(pattern[i] != word[i]):
            return False
    return (len(include_chars_list) == 0)

exec(input()) # DON'T remove this line

6532136721
# 1661522, 2022-10-29 09:27:00, P---- (20%)

def match(word, pattern, include, exclude):
    if len(word) != len(pattern):
        return False
    l = []
    for i in range(len(word)):
        if pattern[i] == '?':
            l.append(word[i])
            continue
        if word[i] != pattern[i]:
            return False
        if word[i] in exclude:
            return False
    if len(include)!=0 and  sorted(l) != sorted(include):
        return False
    return True


exec(input())

# 1661610, 2022-10-29 09:29:19, P--P- (40%)

def match(word, pattern, include, exclude):
    if len(word) != len(pattern):
        return False
    l = []
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude:
                return False
            l.append(word[i])
            continue
        if word[i] != pattern[i]:
            return False
    if len(include)!=0 and sorted(l) != sorted(include):
        return False
    return True


exec(input())

# 1661799, 2022-10-29 09:37:30, PP-P- (60%)

def sum_char(c, word):
    s = 0
    for i in word:
        if c==i:
            s += 1
    return s

def match(word, pattern, include, exclude):
    if len(word) != len(pattern):
        return False
    l = ""
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude:
                return False
            l += word[i]
            continue
        if word[i] != pattern[i]:
            return False

    for i in include:
        if sum_char(i, include) != sum_char(i, l):
            return False

    return True


exec(input())

# 1661846, 2022-10-29 09:39:03, P--P- (40%)

def sum_char(c, word):
    s = 0
    for i in word:
        if c==i:
            s += 1
    return s

def match(word, pattern, include, exclude):
    if len(word) != len(pattern):
        return False
    l = ""
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude:
                return False
            l += word[i]
            continue
        if word[i] != pattern[i]:
            return False

    for i in include:
        if sum_char(i, include) <= sum_char(i, l):
            return False

    return True


exec(input())

# 1661858, 2022-10-29 09:39:14, P--P- (40%)

def sum_char(c, word):
    s = 0
    for i in word:
        if c==i:
            s += 1
    return s

def match(word, pattern, include, exclude):
    if len(word) != len(pattern):
        return False
    l = ""
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude:
                return False
            l += word[i]
            continue
        if word[i] != pattern[i]:
            return False

    for i in include:
        if sum_char(i, include) >= sum_char(i, l):
            return False

    return True


exec(input())

# 1661868, 2022-10-29 09:39:32, P--P- (40%)

def sum_char(c, word):
    s = 0
    for i in word:
        if c==i:
            s += 1
    return s

def match(word, pattern, include, exclude):
    if len(word) != len(pattern):
        return False
    l = ""
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude:
                return False
            l += word[i]
            continue
        if word[i] != pattern[i]:
            return False

    for i in include:
        if sum_char(i, include) < sum_char(i, l):
            return False

    return True


exec(input())

# 1661875, 2022-10-29 09:39:41, PPPPP (100%)

def sum_char(c, word):
    s = 0
    for i in word:
        if c==i:
            s += 1
    return s

def match(word, pattern, include, exclude):
    if len(word) != len(pattern):
        return False
    l = ""
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude:
                return False
            l += word[i]
            continue
        if word[i] != pattern[i]:
            return False

    for i in include:
        if sum_char(i, include) > sum_char(i, l):
            return False

    return True


exec(input())

6532203021
# 1661893, 2022-10-29 09:40:12, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    d_0 = {}
    d = {}
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif pattern[i] == "?" and word[i] in include_chars:
            if word[i] not in d:
                d[word[i]] = 0
            d[word[i]] += 1
    
    for i in include_chars:
        if i not in d_0:
            d_0[i] = 0
        d_0[i] += 1
    
    for key in d:
        if key not in d_0:
            return False
        if d[key] != d_0[key]:
            return False
            
    return True


exec(input()) # DON'T remove this line
# 1662791, 2022-10-29 10:08:53, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    d_0 = {}
    d = {}
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif pattern[i] == "?" and word[i] in include_chars:
            if word[i] not in d:
                d[word[i]] = 0
            d[word[i]] = 1
    
    for i in include_chars:
        if i not in d_0:
            d_0[i] = 0
        d_0[i] += 1
    
    # print(d,d_0)
    for key in d:
        if key not in d_0:
            return False
        if d[key] !=1 or d_0[key] !=1:
            return False
            
    return True


exec(input()) # DON'T remove this line
# print(exec(input()))
# 1662843, 2022-10-29 10:10:16, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    d_0 = {}
    d = {}
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif pattern[i] == "?" and word[i] in include_chars:
            if word[i] not in d:
                d[word[i]] = 0
            d[word[i]] = 1
    
    for i in include_chars:
        if i not in d_0:
            d_0[i] = 0
        d_0[i] = 1
    
    # print(d,d_0)
    for key in d:
        if key not in d_0:
            return False
        if d[key] !=1 or d_0[key] !=1:
            return False
            
    return True


exec(input()) # DON'T remove this line
# print(exec(input()))
# 1662965, 2022-10-29 10:13:48, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    d_0 = {}
    d = {}
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif pattern[i] == "?" and word[i] in include_chars:
            if word[i] not in d:
                d[word[i]] = 0
            d[word[i]] += 1
    
    for i in include_chars:
        if i not in d_0:
            d_0[i] = 0
        d_0[i] += 1
    
    print(d,d_0)
    for key in d:
        if key not in d_0:
            return False
        if d[key] < d_0[key]:
            return False
            
    return True


exec(input()) # DON'T remove this line
# print(exec(input()))
# 1662972, 2022-10-29 10:14:00, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    d_0 = {}
    d = {}
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif pattern[i] == "?" and word[i] in include_chars:
            if word[i] not in d:
                d[word[i]] = 0
            d[word[i]] += 1
    
    for i in include_chars:
        if i not in d_0:
            d_0[i] = 0
        d_0[i] += 1
    
    # print(d,d_0)
    for key in d:
        if key not in d_0:
            return False
        if d[key] < d_0[key]:
            return False
            
    return True


exec(input()) # DON'T remove this line
# print(exec(input()))
# 1663043, 2022-10-29 10:15:40, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    d_0 = {}
    d = {}
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif pattern[i] == "?" and word[i] in include_chars:
            if word[i] not in d:
                d[word[i]] = 0
            d[word[i]] += 1
    
    for i in include_chars:
        if i not in d_0:
            d_0[i] = 0
        d_0[i] += 1
    
    print(d,d_0)
    for key in d_0:
        if key not in d:
            return False
        if d[key] < d_0[key]:
            return False
            
    return True


exec(input()) # DON'T remove this line
# print(exec(input()))
# 1663051, 2022-10-29 10:15:48, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    d_0 = {}
    d = {}
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif pattern[i] == "?" and word[i] in include_chars:
            if word[i] not in d:
                d[word[i]] = 0
            d[word[i]] += 1
    
    for i in include_chars:
        if i not in d_0:
            d_0[i] = 0
        d_0[i] += 1
    
    # print(d,d_0)
    for key in d_0:
        if key not in d:
            return False
        if d[key] < d_0[key]:
            return False
            
    return True


exec(input()) # DON'T remove this line
# print(exec(input()))

6530128321
# 1661626, 2022-10-29 09:30:03, ----- (0%)

print(False)
# 1661640, 2022-10-29 09:30:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  
  return False
exec(input()) # DON'T remove this line
# 1661647, 2022-10-29 09:30:39, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  
  return True
exec(input()) # DON'T remove this line
# 1661904, 2022-10-29 09:40:38, ----- (0%)

def matchq(x,y):
    # pattern, val
    qlet = []
    if (len(x) != len(y)): return [False, []]
    for i in range(len(x)):
        if (x[i]=="?"): qlet.append(y[i])
        elif (x[i]!=y[i]): return [False, []]
    
    return [True, qlet]
        

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern):
        return False
    if not (matchq(word,pattern)[0]):
        return False
    
    qlet = matchq(word,pattern)[1]
    for i in qlet:
        if i in exclude_chars:
            return False
    return True
    

exec(input()) # DON'T remove this line

# 1662095, 2022-10-29 09:47:04, P--P- (40%)

def matchq(x,y):
    # pattern, val
    qlet = []
    if (len(x) != len(y)):
        return [False, []]
    
    for i in range(len(x)):
        if (x[i]=="?"):
            qlet.append(y[i])
            continue
        elif (x[i]!=y[i]):            
            return [False, []]
    
    return [True, qlet]
        

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern):
        return False
    if not (matchq(pattern,word)[0]):
        return False
    
    qlet = matchq(pattern,word)[1]
    for i in qlet:
        if i in exclude_chars:
            return False
    return True
    

exec(input()) # DON'T remove this line

# 1662359, 2022-10-29 09:55:29, PPPPP (100%)

def matchq(x,y):
    # pattern, val
    qlet = []
    if (len(x) != len(y)):
        return [False, []]
    
    for i in range(len(x)):
        if (x[i]=="?"):
            qlet.append(y[i])
            continue
        elif (x[i]!=y[i]):            
            return [False, []]
    
    return [True, qlet]
        

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern):
        return False
    if not (matchq(pattern,word)[0]):
        return False
    
    
    qlet = matchq(pattern,word)[1]
    for i in qlet:
        if i in exclude_chars:
            return False
        
    for i in include_chars:
        if i not in qlet:
            return False
        qlet.remove(i)
        

    return True

    
    

exec(input()) # DON'T remove this line


6531319021
# 1662103, 2022-10-29 09:47:22, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    r = True
    if len(word) != len(pattern):
        r = False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            r = False
    for i in range(len(word)):
        if pattern[i] == '?' and pattern[i] in exclude_chars:
            r = False
    include_chars += '2'
    return r
exec(input()) 
# 1662109, 2022-10-29 09:47:40, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    r = True
    if len(word) != len(pattern):
        r = False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            r = False
    for i in range(len(word)):
        if pattern[i] == '?' and pattern[i] in exclude_chars:
            r = False
    include_chars += '2'
    print(r)
exec(input())
# 1662432, 2022-10-29 09:58:00, xP-Px (40%)

def match(word, pattern, include_chars, exclude_chars):
    r = True
    if len(word) != len(pattern):
        r = False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            r = False
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            r = False
    word2 = list(word)
    for i in include_chars:
        if i not in word2:
            r = False
        else: 
            word2.remove(i)
    return r
exec(input()) 
# 1664027, 2022-10-29 10:35:30, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    word2 = list(word)
    for i in include_chars:
        if i not in word2:
            return False
        else: 
            word2.remove(i)
    return True
exec(input()) 
# 1664136, 2022-10-29 10:37:06, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    word2 = list(word)
    for i in include_chars:
        if i not in word2:
            return False
        elif i in word2:
            word2.remove(i)
    return True
exec(input()) 
# 1664521, 2022-10-29 10:40:46, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    word2 = []
    for i in range(len(pattern)):
        if pattern[i] == '?':
            word2.append(word[i])
    for i in include_chars:
        if i not in word2:
            return False
        elif i in word2:
            word2.remove(i)
    return True
exec(input())

6532141821
# 1661643, 2022-10-29 09:30:32, xxxxx (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    for i in len(word) :
        if len(word) != len(pattern) :
            return False
exec(input())
# 1661679, 2022-10-29 09:31:40, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    for i in range(len(word)) :
        if len(word) != len(pattern) :
            return False
exec(input())
# 1661709, 2022-10-29 09:33:01, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return print(False)
exec(input())
# 1661720, 2022-10-29 09:33:22, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
exec(input())
# 1662125, 2022-10-29 09:48:11, PPPxx (60%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    in_question =  []
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if pattern[i] == "?" :
            in_question.append(word[i])
    for e in list(exclude_chars) :
        for e1 in in_question :
            if e in e1[1] :
                return False
    for e in include_chars :
        try :
            in_question.remove(e)
        except :
            return False
    return True
exec(input())
# 1662179, 2022-10-29 09:49:53, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    in_question =  []
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if pattern[i] == "?" :
            in_question.append(word[i])
    for e in list(exclude_chars) :
        for e1 in in_question :
            if e in e1 :
                return False
    for e in include_chars :
        try :
            in_question.remove(e)
        except :
            return False
    return True
exec(input())

6530118021
# 1663026, 2022-10-29 10:15:21, compilation error (0%)

def match(word,pattern,include_chars,exclude_chars):
  b = True 
  if len(word) != len(pattern):
    b = False
  if b:
    for i in range(len(word)):
      if word[i] != pattern[i] and pattern[i] != '?':
        b = False
        break
  if b:
    l = []
    for i in range(len(pattern)):
      if pattern[i] == '?':
        l.append(i)
    for i in l:
      if word[i] in exclude_chars:
        b = False
        break
return(b)
exec(input())
# 1663044, 2022-10-29 10:15:40, compilation error (0%)

def match(word,pattern,include_chars,exclude_chars):
  b = True 
  if len(word) != len(pattern):
    b = False
  if b:
    for i in range(len(word)):
      if word[i] != pattern[i] and pattern[i] != '?':
      b = False
      break
  if b:
    l = []
    for i in range(len(pattern)):
      if pattern[i] == '?':
      l.append(i)
    for i in l:
      if word[i] in exclude_chars:
      b = False
      break
return(b)
exec(input())
# 1663089, 2022-10-29 10:16:30, compilation error (0%)

def match(word,pattern,include_chars,exclude_chars):
  b = True 
  if len(word) != len(pattern):
    b = False
  if b:
    for i in range(len(word)):
      if word[i] != pattern[i] and pattern[i] != '?':
        b = False
        break
  if b:
    l = []
    for i in range(len(pattern)):
      if pattern[i] == '?':
        l.append(i)
    for i in l:
      if word[i] in exclude_chars:
        b = False
        break
return(b)
exec(input())
# 1663114, 2022-10-29 10:17:24, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars):
  b = True 
  if len(word) != len(pattern):
    b = False
  if b:
    for i in range(len(word)):
      if word[i] != pattern[i] and pattern[i] != '?':
        b = False
        break
  if b:
    l = []
    for i in range(len(pattern)):
      if pattern[i] == '?':
        l.append(i)
    for i in l:
      if word[i] in exclude_chars:
        b = False
        break
  return(b)
exec(input())
# 1663456, 2022-10-29 10:25:06, PPPPP (100%)

def match(word,pattern,include_chars,exclude_chars):
  b = True 
  if len(word) != len(pattern):
    b = False
  if b:
    for i in range(len(word)):
      if word[i] != pattern[i] and pattern[i] != '?':
        b = False
        break
  if b:
    l = []
    for i in range(len(pattern)):
      if pattern[i] == '?':
        l.append(i)
    for i in l:
      if word[i] in exclude_chars:
        b = False
        break
  if b:
    inc = include_chars
    c = ''
    for i in l:
      c += word[i]
    for e in inc:
      if inc.count(e) > c.count(e) or c.count(e) == 0:
        b = False
        break
  return(b)
exec(input())

6530139221
# 1662579, 2022-10-29 10:02:25, xPPPx (60%)

def match(word, pattern, include_chars, exclude_chars):
  LIST = []
  if len(word) == len(pattern):
    for i in range(len(word)):
      if pattern[i] != '?' and word[i] != pattern[i]:
        #print(1)
        return False
      if pattern[i] == '?' and word[i] in exclude_chars:
        #print(2)
        return False

  for i in range(len(word)):
    if pattern[i] == '?':
      LIST.append(word[i])

  #print(LIST)
  for i in include_chars:
    if i not in LIST:
      #print(3)
      return False
    else:
      INDEX = LIST.index(i)
      LIST.pop(INDEX)

  return True
      
    
'''print(match("MACMA", "M?C??", "MAA", ""))
print(match("MACMA", "M?C??", "AM", ""))
print(match("MACMA", "M?C??", "", ""))
print(match("MACMA", "M?C??", "", "CPE"))
print(match("MACMA", "?????", "AAMM", "OK"))
print(match("MACMA", "MACMA", "", "MACMA"))'''


exec(input())     # DON'T remove this line
# 1662640, 2022-10-29 10:04:22, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
  LIST = []
  if len(word) == len(pattern):
    for i in range(len(word)):
      if pattern[i] != '?' and word[i] != pattern[i]:
        #print(1)
        return False
      if pattern[i] == '?' and word[i] in exclude_chars:
        #print(2)
        return False

  for i in range(len(word)):
    if pattern[i] == '?':
      LIST.append(word[i])

  #print(LIST)
  for i in include_chars:
    if i not in LIST:
      #print(3)
      return False
    else:
      INDEX = LIST.index(i)
      LIST.pop(INDEX)

  return True
      
    
print(match("MACMA", "M?C??", "MAA", ""))
print(match("MACMA", "M?C??", "AM", ""))
print(match("MACMA", "M?C??", "", ""))
print(match("MACMA", "M?C??", "", "CPE"))
print(match("MACMA", "?????", "AAMM", "OK"))
print(match("MACMA", "MACMA", "", "MACMA"))


exec(input())     # DON'T remove this line
# 1662665, 2022-10-29 10:05:08, xPPPx (60%)

def match(word, pattern, include_chars, exclude_chars):
  LIST = []
  if len(word) == len(pattern):
    for i in range(len(word)):
      if pattern[i] != '?' and word[i] != pattern[i]:
        #print(1)
        return False
      if pattern[i] == '?' and word[i] in exclude_chars:
        #print(2)
        return False

  for i in range(len(word)):
    if pattern[i] == '?':
      LIST.append(word[i])

  #print(LIST)
  for i in include_chars:
    if i not in LIST:
      #print(3)
      return False
    else:
      INDEX = LIST.index(i)
      LIST.pop(INDEX)

  return True
      
    
'''print(match("MACMA", "M?C??", "MAA", ""))
print(match("MACMA", "M?C??", "AM", ""))
print(match("MACMA", "M?C??", "", ""))
print(match("MACMA", "M?C??", "", "CPE"))
print(match("MACMA", "?????", "AAMM", "OK"))
print(match("MACMA", "MACMA", "", "MACMA"))'''


exec(input())     # DON'T remove this line
# 1663899, 2022-10-29 10:33:29, xPPPx (60%)

def match(word, pattern, include_chars, exclude_chars):
  LIST = []
  if len(word) == len(pattern):
    for i in range(len(word)):
      if pattern[i] != '?' and word[i] != pattern[i]:
        #print(1)
        return False
      if pattern[i] == '?' and word[i] in exclude_chars:
        #print(2)
        return False

  for i in range(len(word)):
    if pattern[i] == '?':
      LIST.append(word[i])

  #print(LIST)
  for i in include_chars:
    if i not in LIST:
      #print(3)
      return False
    else:
      INDEX = LIST.index(i)
      LIST.pop(INDEX)

  return True
      
    
'''print(match("MACMA", "M?C??", "MAA", ""))
print(match("MACMA", "M?C??", "AM", ""))
print(match("MACMA", "M?C??", "", ""))
print(match("MACMA", "M?C??", "", "CPE"))
print(match("MACMA", "?????", "AAMM", "OK"))
print(match("MACMA", "MACMA", "", "MACMA"))'''


exec(input())     # DON'T remove this line

# 1663962, 2022-10-29 10:34:29, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
  LIST = []
  if len(word) == len(pattern):
    for i in range(len(word)):
      if pattern[i] != '?' and word[i] != pattern[i]:
        #print(1)
        return False
      if pattern[i] == '?' and word[i] in exclude_chars:
        #print(2)
        return False
  else:
    return False

  for i in range(len(word)):
    if pattern[i] == '?':
      LIST.append(word[i])

  #print(LIST)
  for i in include_chars:
    if i not in LIST:
      #print(3)
      return False
    else:
      INDEX = LIST.index(i)
      LIST.pop(INDEX)

  return True
      
    
'''print(match("MACMA", "M?C??", "MAA", ""))
print(match("MACMA", "M?C??", "AM", ""))
print(match("MACMA", "M?C??", "", ""))
print(match("MACMA", "M?C??", "", "CPE"))
print(match("MACMA", "?????", "AAMM", "OK"))
print(match("MACMA", "MACMA", "", "MACMA"))
print(match("MACMA", "M?C??", "AAA", ""))
print(match("MACMA", "M?C??", "MAX", ""))
print(match("MACMA", "M?C??", "C", ""))
print(match("MACMA", "M?C??", "", "MX"))
print(match("MACMA", "M?C???", "", ""))
print(match("MACMA", "M?C?", "", ""))'''


exec(input())     # DON'T remove this line

6530174121
# 1662840, 2022-10-29 10:10:13, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    pattern_order = []
    q_order = []
    c= 0
    for e in pattern:
        if e != "?":
            pattern_order.append(pattern.find(e))
        else:
            q_order.append(pattern.find(e,c))
    for e in pattern_order:
        if word[e] != pattern[e]:
            return False
    for e in q_order:
        if word[e] in exclude_chars:
            return False
        char_dict = {}
    for e in include_chars:
        if e not in char_dict:
            char_dict[e] = 1
        else:
            char_dict[e] += 1
    return True
exec(input())
# 1663136, 2022-10-29 10:17:58, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    pattern_order = []
    q_order = []
    c= 0
    for e in pattern:
        if e != "?":
            pattern_order.append(pattern.find(e))
        else:
            q_order.append(pattern.find(e,c))
    for e in pattern_order:
        if word[e] != pattern[e]:
            return False
    for e in q_order:
        if word[e] in exclude_chars:
            return False
        char_dict = {}
    for e in include_chars:
        if e not in char_dict:
            char_dict[e] = 1
        else:
            char_dict[e] += 1
    word_dict = {}
    for e in q_order:
        if e not in word_dict:
            word_dict[word[e]] = 1
        else:
            word_dict[word[e]] += 1
    print(char_dict,word_dict)
    for e in char_dict:
        pass
    return True
exec(input())
# 1663316, 2022-10-29 10:22:23, xxxPx (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    pattern_order = []
    q_order = []
    c= 0
    for e in pattern:
        if e != "?":
            pattern_order.append(pattern.find(e))
        else:
            q_order.append(pattern.find(e,c))
            c = pattern.find(e,c)+1
    for e in pattern_order:
        if word[e] != pattern[e]:
            return False
    for e in q_order:
        if word[e] in exclude_chars:
            return False
        char_dict = {}
    for e in include_chars:
        if e not in char_dict:
            char_dict[e] = 1
        else:
            char_dict[e] += 1
    word_dict = {}
    for e in q_order:
        if word[e] not in word_dict:
            word_dict[word[e]] = 1
        else:
            word_dict[word[e]] += 1
    for e in char_dict:
        if char_dict[e] > word_dict[e]:
            return False
    return True
exec(input())
# 1663553, 2022-10-29 10:26:56, xPPPx (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    pattern_order = []
    q_order = []
    c= 0
    for e in pattern:
        if e != "?":
            pattern_order.append(pattern.find(e))
        else:
            q_order.append(pattern.find(e,c))
            c = pattern.find(e,c)+1
    for e in pattern_order:
        if word[e] != pattern[e]:
            return False
    for e in q_order:
        if word[e] in exclude_chars:
            return False
        char_dict = {}
    for e in include_chars:
        if e not in char_dict:
            char_dict[e] = 1
        else:
            char_dict[e] += 1
    word_dict = {}
    for e in q_order:
        if word[e] not in word_dict:
            word_dict[word[e]] = 1
        else:
            word_dict[word[e]] += 1
    for e in char_dict:
        if e not in word_dict:
            return False
        elif char_dict[e] > word_dict[e]:
            return False
    return True
exec(input())
# 1663656, 2022-10-29 10:28:57, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    pattern_order = []
    q_order = []
    c= 0
    for e in pattern:
        if e != "?":
            pattern_order.append(pattern.find(e))
        else:
            q_order.append(pattern.find(e,c))
            c = pattern.find(e,c)+1
    for e in pattern_order:
        if word[e] != pattern[e]:
            return False
    for e in q_order:
        if word[e] in exclude_chars:
            return False
        char_dict = {}
    for e in include_chars:
        if e not in char_dict:
            char_dict[e] = 1
        else:
            char_dict[e] += 1
    word_dict = {}
    for e in q_order:
        if word[e] not in word_dict:
            word_dict[word[e]] = 1
        else:
            word_dict[word[e]] += 1
    for e in char_dict:
        if e not in word_dict:
            return False
        elif char_dict[e] > word_dict[e]:
            return False
    return True
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    pattern_order = []
    q_order = []
    c= 0
    for e in pattern:
        if e != "?":
            pattern_order.append(pattern.find(e))
        else:
            q_order.append(pattern.find(e,c))
            c = pattern.find(e,c)+1
    for e in pattern_order:
        if word[e] != pattern[e]:
            return False
    for e in q_order:
        if word[e] in exclude_chars:
            return False
    char_dict = {}
    for e in include_chars:
        if e not in char_dict:
            char_dict[e] = 1
        else:
            char_dict[e] += 1
    word_dict = {}
    for e in q_order:
        if word[e] not in word_dict:
            word_dict[word[e]] = 1
        else:
            word_dict[word[e]] += 1
    for e in char_dict:
        if e not in word_dict:
            return False
        elif char_dict[e] > word_dict[e]:
            return False
    return True
exec(input())

6531308121
# 1661667, 2022-10-29 09:31:12, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return False
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
    #for i in range(len(include_chars)) :       
    return True
exec(input()) 
# 1662638, 2022-10-29 10:04:21, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return False
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
    for i in range(len(include_chars)) :
        if inclue_chars[i] not in word :
            return False
    return True
exec(input())
# 1662658, 2022-10-29 10:04:53, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return False
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
    for i in range(len(include_chars)) :
        if include_chars[i] not in word :
            return False
    return True
exec(input())
# 1662901, 2022-10-29 10:12:06, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    lw = {}
    check = {}
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return False
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
    for i in range(len(include_chars)) :
        if include_chars[i] not in word :
            return False
    ########
    for i in word :
        if i not in lw :
            lw[i] = 1
        else :
            lw[i] += 1
    for i in pattern :
        if i != '?' :
            if i not in check :
                check[i] = 1
            else :
                check[i] += 1
    for i in include_chars  :
        if i not in check :
            check[i] = 1
        else :
            check[i] += 1
            
    for i in check :
        if check[i] > lw[i] :
            return False
    return True
exec(input())
# 1663101, 2022-10-29 10:16:51, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return False
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
    for i in range(len(include_chars)) :
        if include_chars[i] not in word :
            return False
    ########
    lw = {}
    check = {}
    for i in word :
        if i not in lw :
            lw[i] = 1
        else :
            lw[i] += 1
    for i in pattern :
        if i != '?' :
            if i not in check :
                check[i] = 1
            else :
                check[i] += 1
    for i in include_chars  :
        if i not in check :
            check[i] = 1
        else :
            check[i] += 1            
    for i in check :
        if check[i] > lw[i] :
            return False
    return True
exec(input())

6531313221
# 1661721, 2022-10-29 09:33:30, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    have_char = []
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            have_char += word[i]
        if pattern[i] != word[i]:
            return False
    return sorted(have_char) == sorted(list(include_chars))


exec(input())

# 1661757, 2022-10-29 09:35:30, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    have_char = []
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            have_char += word[i]
        elif pattern[i] != word[i]:
            return False
    return sorted(have_char) == sorted(list(include_chars))


exec(input())

# 1662801, 2022-10-29 10:09:04, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    dict_word = {}
    if len(word) != len(pattern):
        return False
    have_char = []
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            if word[i] in dict_word:
                dict_word[word[i]] += 1
            else:
                dict_word[word[i]] = 1
        elif pattern[i] != word[i]:
            return False

    for c in include_chars:
        if c not in dict_word:
            return False
        if dict_word[c] == 0:
            return False
        dict_word[c] -= 1
    return True


exec(input())
# print(exec(input()))

# 1664046, 2022-10-29 10:35:49, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    dict_word = {}
    if len(word) != len(pattern):
        return False
    have_char = []
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            if word[i] in dict_word:
                dict_word[word[i]] += 1
            else:
                dict_word[word[i]] = 1
        elif pattern[i] != word[i]:
            return False

    for c in include_chars:
        if c not in dict_word:
            return False
        if dict_word[c] == 0:
            return False
        dict_word[c] -= 1
    return True


exec(input())
# 1664318, 2022-10-29 10:39:04, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    dict_word = {}
    if len(word) != len(pattern):
        return False
    have_char = []
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            if word[i] in dict_word:
                dict_word[word[i]] += 1
            else:
                dict_word[word[i]] = 1
        elif pattern[i] != word[i]:
            return False

    for c in include_chars:
        if c not in dict_word:
            return False
        if dict_word[c] == 0:
            return False
        dict_word[c] -= 1
    return True


exec(input())

6532193421
# 1661916, 2022-10-29 09:40:57, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)):
        return False
    a=set()
    b=set(include_chars)
    for i in range(len(word)):
        if (pattern[i]!='?' and word[i]!=pattern[i]):
            return False
        elif (pattern[i]=='?'):
            if word[i] in exclude_chars:
                return False
            a.add(word[i])
    if (a<=b and b<=a) or len(include_chars)==0:
        return True
    return False
exec(input()) # DON'T remove this line
# 1661974, 2022-10-29 09:43:08, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)):
        return False
    a={}
    b={}
    for c in include_chars:
        if c not in b:
            b[c]=0
        b[c]+=1
    for i in range(len(word)):
        if (pattern[i]!='?' and word[i]!=pattern[i]):
            return False
        elif (pattern[i]=='?'):
            if word[i] in exclude_chars:
                return False
            if word[i] not in a:
                a[word[i]]=0
            a[word[i]]+=1
    for k in b.keys():
        if b[k]!=a[k]:
            return False
    return True
exec(input()) # DON'T remove this line
# 1661991, 2022-10-29 09:43:44, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)):
        return False
    a={}
    b={}
    for c in include_chars:
        if c not in b:
            b[c]=0
        b[c]+=1
    for i in range(len(word)):
        if (pattern[i]!='?' and word[i]!=pattern[i]):
            return False
        elif (pattern[i]=='?'):
            if word[i] in exclude_chars:
                return False
            if word[i] not in a:
                a[word[i]]=0
            a[word[i]]+=1
    for k in b.keys():
        if k not in a or (b[k]!=a[k]):
            return False
    return True
exec(input()) # DON'T remove this line
# 1662106, 2022-10-29 09:47:32, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)):
        return False
    a={}
    b={}
    for c in include_chars:
        if c not in b:
            b[c]=0
        b[c]+=1
    for i in range(len(word)):
        if (pattern[i]!='?' and word[i]!=pattern[i]):
            return False
        elif (pattern[i]=='?'):
            if word[i] in exclude_chars:
                return False
            if word[i] not in a:
                a[word[i]]=0
            a[word[i]]+=1
    for k in b.keys():
        if k not in a or (b[k]<=a[k]):
            return False
    return True
exec(input()) # DON'T remove this line
# 1662118, 2022-10-29 09:47:58, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)):
        return False
    a={}
    b={}
    for c in include_chars:
        if c not in b:
            b[c]=0
        b[c]+=1
    for i in range(len(word)):
        if (pattern[i]!='?' and word[i]!=pattern[i]):
            return False
        elif (pattern[i]=='?'):
            if word[i] in exclude_chars:
                return False
            if word[i] not in a:
                a[word[i]]=0
            a[word[i]]+=1
    for k in b.keys():
        if k not in a or (b[k]>a[k]):
            return False
    return True
exec(input()) # DON'T remove this line

6532201821
# 1662066, 2022-10-29 09:46:10, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ind=[]
    for i in range(len(pattern)) :
        if pattern[i]=='?' : ind.append(i)

    if len(word) != len(pattern) : 
       # print('1')
        return False

    for i in range(len(word)):
        if pattern[i]=='?' : continue
        if word[i]!=pattern[i] : 
          #  print('2')
            return False
    
    for j in ind:
        if word[j] in exclude_chars : 
           # print('3')
            return False

    str1=''
    str2=''
    for j in ind:str1+=word[j]
    for i in include_chars:str2+=i
    #str1.sort()
    #str2.sort()
    
    if str2 not in str1 :
        #print(str2)
        #print(str1)
        #print('4')
        return False

    return True

#print(match("MACMA", "M?C??", "MAX", "") )
    #return ind
exec(input())

#match("MACMA", "M?C??", "MAA", "")
# 1662074, 2022-10-29 09:46:24, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ind=[]
    for i in range(len(pattern)) :
        if pattern[i]=='?' : ind.append(i)

    if len(word) != len(pattern) : 
       # print('1')
        return False

    for i in range(len(word)):
        if pattern[i]=='?' : continue
        if word[i]!=pattern[i] : 
          #  print('2')
            return False
    
    for j in ind:
        if word[j] in exclude_chars : 
           # print('3')
            return False

    str1=''
    str2=''
    for j in ind:str1+=word[j]
    for i in include_chars:str2+=i
    #str1.sort()
    #str2.sort()
    
    if str2 not in str1 :
        #print(str2)
        #print(str1)
        #print('4')
        return False

    return True

#print(match("MACMA", "M?C??", "MAX", "") )
    #return ind
exec(input())

#match("MACMA", "M?C??", "MAA", "")
# 1662086, 2022-10-29 09:46:56, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    ind=[]
    for i in range(len(pattern)) :
        if pattern[i]=='?' : ind.append(i)

    if len(word) != len(pattern) : 
       # print('1')
        return False

    for i in range(len(word)):
        if pattern[i]=='?' : continue
        if word[i]!=pattern[i] : 
          #  print('2')
            return False
    
    for j in ind:
        if word[j] in exclude_chars : 
           # print('3')
            return False

    # str1=''
    # str2=''
    # for j in ind:str1+=word[j]
    # for i in include_chars:str2+=i
    # #str1.sort()
    # #str2.sort()
    
    # if str2 not in str1 :
    #     #print(str2)
    #     #print(str1)
    #     #print('4')
    #     return False

    # return True

#print(match("MACMA", "M?C??", "MAX", "") )
    #return ind
exec(input())

#match("MACMA", "M?C??", "MAA", "")
# 1662100, 2022-10-29 09:47:09, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ind=[]
    for i in range(len(pattern)) :
        if pattern[i]=='?' : ind.append(i)

    if len(word) != len(pattern) : 
       # print('1')
        return False

    for i in range(len(word)):
        if pattern[i]=='?' : continue
        if word[i]!=pattern[i] : 
          #  print('2')
            return False
    
    for j in ind:
        if word[j] in exclude_chars : 
           # print('3')
            return False

    # str1=''
    # str2=''
    # for j in ind:str1+=word[j]
    # for i in include_chars:str2+=i
    # #str1.sort()
    # #str2.sort()
    
    # if str2 not in str1 :
    #     #print(str2)
    #     #print(str1)
    #     #print('4')
    #     return False

    return True

#print(match("MACMA", "M?C??", "MAX", "") )
    #return ind
exec(input())

#match("MACMA", "M?C??", "MAA", "")
# 1662145, 2022-10-29 09:49:02, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    ind=[]
    for i in range(len(pattern)) :
        if pattern[i]=='?' : ind.append(i)

    if len(word) != len(pattern) : 
       # print('1')
        return False

    for i in range(len(word)):
        if pattern[i]=='?' : continue
        if word[i]!=pattern[i] : 
          #  print('2')
            return False
    
    for j in ind:
        if word[j] in exclude_chars : 
           # print('3')
            return False

    str1=[]
    str2=[]
    for j in ind:str1.append(word[j])
    for i in include_chars:str2.append(i)
    str1.sort()
    str2.sort()
    s1=''
    s2=''
    for i in str1: s1+=i
    for i in str2: s2+=i
    
    if s2 not in s1 :
        #print(str2)
        #print(str1)
        #print('4')
        return False

    return True

#print(match("MACMA", "M?C??", "MAX", "") )
    #return ind
exec(input())

#match("MACMA", "M?C??", "MAA", "")

6231422721
# 1661882, 2022-10-29 09:39:51, x---x (0%)

def match(a,b,c,d) :
    if len(a) == len([e for e in b if e!= "?"]) :
        return True
    count = 0
    for i in range (len(a)) :
        if a[i] == b[i] :
            count += 1
    if count == len([e for e in b if e!= "?"]) :
        return True
    t = list(c)
    for i in range (len(a)) :
        if b[i] == "?" and a[i] in t :
            t.remove(a[i])
    for i in range (len(a)) :
        if b[i] == "?" and a[i] in d and t == [] :
            return True
    return False
        
exec(input()) # DON'T remove this line
# 1662110, 2022-10-29 09:47:40, x---x (0%)

def match(a,b,c,d) :
    if len(a) == len([e for e in b if e!= "?"]) :
        return True
    count = 0
    for i in range (len(a)) :
        if a[i] == b[i] :
            count += 1
    if count == len([e for e in b if e!= "?"]) :
        return True
    t = list(c)
    for i in range (len(a)) :
        if b[i] == "?" and a[i] in t :
            t.remove(a[i])
    for i in range (len(a)) :
        if b[i] == "?" and a[i] in d and t == [] :
            return True
    print(False)
        
exec(input()) # DON'T remove this line
# 1662114, 2022-10-29 09:47:51, x---x (0%)

def match(a,b,c,d) :
    if len(a) == len([e for e in b if e!= "?"]) :
        return True
    count = 0
    for i in range (len(a)) :
        if a[i] == b[i] :
            count += 1
    if count == len([e for e in b if e!= "?"]) :
        return True
    t = list(c)
    for i in range (len(a)) :
        if b[i] == "?" and a[i] in t :
            t.remove(a[i])
    for i in range (len(a)) :
        if b[i] == "?" and a[i] in d and t == [] :
            return True
    return True
        
exec(input()) # DON'T remove this line
# 1662675, 2022-10-29 10:05:28, PPPPP (100%)

def match(a,b,c,d) :
    if len(a) != len(b) :
        return False
    count = 0
    for i in range (len(a)) :
        if a[i] == b[i] :
            count += 1
    if count != len([e for e in b if e!= "?"]) :
        return False
    t = list(c)
    for i in range (len(a)) :
        if b[i] == "?" and a[i] in t :
            t.remove(a[i])
    if t != [] :
        return False
    for i in range (len(a)) :
        if b[i] == "?" and a[i] in d  :
            return False
    return True
        
exec(input()) # DON'T remove this line

6530105921
# 1662083, 2022-10-29 09:46:50, PP-P- (60%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):  #1
        return False
    lock = []
    for i in range(len(pattern)):
        if pattern[i] != "?":
            lock += [i]
    for e in lock:      #2
        if word[e] != pattern[e]:
            return False
    wordch = []
    for k in word:
        wordch += [k]
    for j in include_chars:  #3
        if j in wordch:
            wordch.remove(j)
        else:
            return False
    for q in exclude_chars: #4
        if q in word:
            return False
    return True
exec(input())
# 1662329, 2022-10-29 09:54:36, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):  #1   print(match("MACMA", "M?C?", "", ""))
        return False
    lock = []
    free = []
    for i in range(len(pattern)):
        if pattern[i] != "?":
            lock += [i]
        else:
            free += [i]
    for e in lock:      #2
        if word[e] != pattern[e]:
            return False
    wordchl = []
    wordchf1 = []
    for k in free:
        wordchf1 += [k]
    wordchf2 = wordchf1
    for j in include_chars:  #3
        if j in wordchf1:
            wordch.remove(j)
        else:
            return False
    for q in exclude_chars: #4
        if q in wordchf2:
            return False
    return True
exec(input())
# 1662362, 2022-10-29 09:55:38, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):  #1   print(match("MACMA", "M?C?", "", ""))
        return False
    lock = []
    free = []
    for i in range(len(pattern)):
        if pattern[i] != "?":
            lock += [i]
        else:
            free += [i]
    for e in lock:      #2
        if word[e] != pattern[e]:
            return False
    wordchf1 = []
    for k in free:
        wordchf1 += [k]
    wordchf2 = wordchf1
    for j in include_chars:  #3
        if j in wordchf1:
            wordchf1.remove(j)
        else:
            return False
    for q in exclude_chars: #4
        if q in wordchf2:
            return False
    return True
exec(input())
# 1662448, 2022-10-29 09:58:18, PPPPP (100%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):  #1   print(match("MACMA", "M?C?", "", ""))
        return False
    lock = []
    free = []
    for i in range(len(pattern)):
        if pattern[i] != "?":
            lock += [i]
        else:
            free += [i]
    for e in lock:      #2
        if word[e] != pattern[e]:
            return False
    wordchf1 = []
    for k in free:
        wordchf1 += [word[k]]
    wordchf2 = wordchf1
    for j in include_chars:  #3
        if j in wordchf1:
            wordchf1.remove(j)
        else:
            return False
    for q in exclude_chars: #4
        if q in wordchf2:
            return False
    return True
exec(input())

6530168421
# 1662045, 2022-10-29 09:45:24, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            inc.append(word[i])
    check = []
    for e in include_chars:
        check.append(e)
    inc.sort() ; check.sort()
    if inc != check:
        return False
    return True
exec(input()) # DON'T remove this line
# 1662305, 2022-10-29 09:53:40, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern):
        print(False)
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and pattern[i] != word[i]:
                print(False) ; break
            elif pattern[i] == '?':
                if word[i] in exclude_chars:
                    print(False) ; break
                inc.append(word[i])
            else:
                pass
        check = []
        for e in include_chars:
            check.append(e)
        inc.sort() ; check.sort()
        if inc != check:
            print(False)
        else:
            print(True)
exec(input()) # DON'T remove this line

# 1662888, 2022-10-29 10:11:45, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            inc.append(word[i])
    check = []
    for e in include_chars:
        check.append(e)
    inc.sort() ; check.sort()
    for e in check:
        if e not in inc:
            return False
    return True
exec(input()) # DON'T remove this line
# 1664401, 2022-10-29 10:39:51, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        elif pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            inc.append(word[i])
    check = []
    for e in include_chars:
        check.append(e)
    inc.sort() ; check.sort()
    for e in inc:
        if e in check:
            check.remove(e)
    if check != []:
        return False
    return True
exec(input()) # DON'T remove this line

6530175821
# 1662433, 2022-10-29 09:58:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != "?" :
            if word[i] != pattern[i] :
                return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                return False
    include_chars = list(include_chars)
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in include_chars :
                include_chars.remove(word[i])
            elif word[i] not in include_chars :
                return False
    return True
    
exec(input())

# 1662755, 2022-10-29 10:07:59, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        print(False)
        return False
    for i in range(len(word)) :
        if pattern[i] != "?" :
            if word[i] != pattern[i] :
                print(False)
                return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                print(False)
                return False
    include_chars = list(include_chars)
    for i in range(len(word)) :
        if pattern[i] == "?" and include_chars != []:
            if word[i] in include_chars :
                include_chars.remove(word[i])
    if include_chars != [] :
        print(False)
        return False
    print(True)
    return True
    
exec(input())

# 1662797, 2022-10-29 10:08:58, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        print(False)
        return False
    for i in range(len(word)) :
        if pattern[i] != "?" :
            if word[i] != pattern[i] :
                print(False)
                return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                print(False)
                return False
    include_chars = list(include_chars)
    for i in range(len(word)) :
        if pattern[i] == "?" and include_chars != []:
            if word[i] in include_chars :
                include_chars.remove(word[i])
    if include_chars != [] :
        print(False)
        return False
    print(True)
    return True
    
exec(input()) # DON'T remove this line
# 1662810, 2022-10-29 10:09:18, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != "?" :
            if word[i] != pattern[i] :
                return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars :
                return False
    include_chars = list(include_chars)
    for i in range(len(word)) :
        if pattern[i] == "?" and include_chars != []:
            if word[i] in include_chars :
                include_chars.remove(word[i])
    if include_chars != [] :
        return False
    return True
    
exec(input()) # DON'T remove this line

6531344721
# 1663202, 2022-10-29 10:19:36, P--P- (40%)

def checkp(a, b):
    if len(a) != len(b):
        return False
    for i in range(len(a)):
        if a[i] != "?" and a[i] != b[i]:
            return False
    return True


def checke(a, b, e):
    for i in range(len(a)):
        if a[i] == "?" and b[i] in e:
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if word == pattern:
        return True
    if checkp(pattern, word) and checke(pattern, word, exclude_chars):
        return True
    return False


exec(input())
# 1663419, 2022-10-29 10:24:22, ----- (0%)

def checkp(a, b):
    if len(a) != len(b):
        return False
    for i in range(len(a)):
        if a[i] != "?" and a[i] != b[i]:
            return False
    return True


def checke(a, b, e):
    for i in range(len(a)):
        if a[i] == "?" and b[i] in e:
            return False
    return True
def checki(a, b, t):
    d = ""
    for i in range(len(a)):
        if a[i] == "?":
            d += b[i]
    for e in t:
        if e not in d:
            return False


def match(word, pattern, include_chars, exclude_chars):
    if word == pattern:
        return True
    if checkp(pattern, word) and checke(pattern, word, exclude_chars) and checki(pattern,word,include_chars):
        return True
    
    return False


exec(input())
# 1663430, 2022-10-29 10:24:38, PP-P- (60%)

def checkp(a, b):
    if len(a) != len(b):
        return False
    for i in range(len(a)):
        if a[i] != "?" and a[i] != b[i]:
            return False
    return True


def checke(a, b, e):
    for i in range(len(a)):
        if a[i] == "?" and b[i] in e:
            return False
    return True
def checki(a, b, t):
    d = ""
    for i in range(len(a)):
        if a[i] == "?":
            d += b[i]
    for e in t:
        if e not in d:
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if word == pattern:
        return True
    if checkp(pattern, word) and checke(pattern, word, exclude_chars) and checki(pattern,word,include_chars):
        return True
    
    return False


exec(input())
# 1664170, 2022-10-29 10:37:32, PPPPP (100%)

def checkp(a, b):
    if len(a) != len(b):
        return False
    for i in range(len(a)):
        if a[i] != "?" and a[i] != b[i]:
            return False
    return True

def count(a, b):
    c = 0
    s = 0
    i = 0
    while s != -1:
        s = b.find(a, i)
        if s != -1:
            c += 1
        if s == -1:
            break
        i = s+1
    return c


def checke(a, b, e):
    for i in range(len(a)):
        if a[i] == "?" and b[i] in e:
            return False
    return True
def checki(a, b, t):
    d = ""
    for i in range(len(a)):
        if a[i] == "?":
            d += b[i]
    
    d1=""
    for e in t:
        if e not in d:
            return False
        if e in d:
            d1+=e
    for e in t:
        if count(e,t)>count(e,d):
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if word == pattern:
        return True
    if checkp(pattern, word) and checke(pattern, word, exclude_chars) and checki(pattern,word,include_chars):
        return True
    
    return False


exec(input())

6532120621
# 1661683, 2022-10-29 09:31:48, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for x, y in zip(word, pattern):
        if y == '?':
            if x in exclude_chars:
                return False
        elif x != y:
            return False
    w_c = {}
    i_c = {}
    for letter in word:
        if letter not in w_c:
            w_c[letter] = word.count(letter)
    for letter in include_chars:
        if letter not in i_c:
            i_c[letter] = include_chars.count(letter)

    for k, v in i_c.items():
        if k not in w_c or v > w_c[k]:
            return False

    return True

exec(input()) # DON'T remove this line

# 1661729, 2022-10-29 09:34:07, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    w_c = {}
    for x, y in zip(word, pattern):
        if y == '?':
            if x in exclude_chars:
                return False
            else:
                if x not in w_c:
                    w_c[x] = 0
                w_c[x] += 1
        elif x != y:
            return False
    w_c = {}
    i_c = {}
    for letter in include_chars:
        if letter not in i_c:
            i_c[letter] = include_chars.count(letter)

    for k, v in i_c.items():
        if k not in w_c or v > w_c[k]:
            return False

    return True

exec(input()) # DON'T remove this line

# 1662353, 2022-10-29 09:55:20, -PP-- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    w_c = {}
    for x, y in zip(word, pattern):
        if y == '?':
            if x in exclude_chars:
                print(1)
                return False
            else:
                if x not in w_c:
                    w_c[x] = 0
                w_c[x] += 1
        elif x != y:
            print(2)
            return False
    i_c = {}
    for letter in include_chars:
        if letter not in i_c:
            i_c[letter] = include_chars.count(letter)

    for k, v in i_c.items():
        if k not in w_c or v > w_c[k]:
            return False

    return True

exec(input()) # DON'T remove this line

# 1662363, 2022-10-29 09:55:40, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    w_c = {}
    for x, y in zip(word, pattern):
        if y == '?':
            if x in exclude_chars:
                return False
            else:
                if x not in w_c:
                    w_c[x] = 0
                w_c[x] += 1
        elif x != y:
            return False
    i_c = {}
    for letter in include_chars:
        if letter not in i_c:
            i_c[letter] = include_chars.count(letter)

    for k, v in i_c.items():
        if k not in w_c or v > w_c[k]:
            return False

    return True

exec(input()) # DON'T remove this line


6532124121
# 1661435, 2022-10-29 09:24:28, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i]=="?"):
            continue
        elif(pattern[i]!=word[i]):
            return False
    f2 = True

    return True

exec(input())
# 1661492, 2022-10-29 09:25:59, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i]=="?"):
            if(word[i] in exclude_chars):
                return False
            continue
        elif(pattern[i]!=word[i]):
            return False
    f2 = True

    return True

exec(input())
# 1661596, 2022-10-29 09:28:54, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i]=="?"):
            if(word[i] in include_chars):
                include_chars.remove(word[i])
            if(word[i] in exclude_chars):
                return False
            continue
        elif(pattern[i]!=word[i]):
            return False
    if(len(include_chars)>0):
        return False

    return True

exec(input())
# 1661675, 2022-10-29 09:31:27, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    l = []
    for i in include_chars:
        l.append(i)
    if(len(word)!=len(pattern)):
        return False
    for i in range(len(word)):
        if(pattern[i]=="?"):
            if(word[i] in l):
                l.remove(word[i])
            if(word[i] in exclude_chars):
                return False
            continue
        elif(pattern[i]!=word[i]):
            return False
    if(len(l)>0):
        return False

    return True

exec(input())

6531019821
# 1662230, 2022-10-29 09:51:16, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    y = []
    for i in range(len(pattern)):
        if i == '?':
            y.append(i)
    if y != []:
        for e in y:
            if word[e] in exclude_chars:
                return False
    if len(include_chars) > len(word):
        return False
    
    return True

exec(input())
# 1662489, 2022-10-29 09:59:20, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    y = []
    for i in range(len(pattern)):
        if i == '?':
            y.append(i)
    if y != []:
        for e in y:
            if word[e] in exclude_chars:
                return False
    if len(include_chars) > len(word):
        return False
    
    word1 = list(word)
    for e in include_chars:
        if e not in word1:
            return False
        else:
            word1.remove(e)
    return True

exec(input()) # DON'T remove this line

# 1662858, 2022-10-29 10:10:42, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    y = []
    for i in range(len(pattern)):
        if pattern[i] == '?':
            y.append(i)
    if y != [] and exclude_chars != []:
        for e in y:
            if word[e] in exclude_chars:
                return False
    if len(include_chars) > len(word):
        return False
    
    word1 = list(word)
    for e in include_chars:
        if e not in word1 :
            return False
        else:
            word1.remove(e)
    return True

exec(input()) 
# 1663047, 2022-10-29 10:15:42, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    y = []
    for i in range(len(pattern)):
        if pattern[i] == '?':
            y.append(i)
    if y != [] and exclude_chars != []:
        for e in y:
            if word[e] in exclude_chars:
                return False
    if len(include_chars) > len(word):
        return False
    
    word1 = []
    for e in y:
        word1.append(word[e])
    for e in include_chars:
        if e not in word1 :
            return False
        else:
            word1.remove(e)
    return True

exec(input()) # DON'T remove this line


6432036521
# 1663243, 2022-10-29 10:20:25, xxx-x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):return False

    for i in range(len(word)):
        if pattern[i]!='?' and word[i]!=pattern[i]:
            return False

    for i in range(len(word)):
        if pattern[i]=='?' and word[i] in exclude_chars:
            return False

    for i in range(len(word)):
        if pattern[i]=='?':
            index = include_chars.find(word[i])
            if index==-1:
                return False
            else:
                include_chars.pop(index)
    if len(incluce_chars)!=0:return False

    return True

exec(input()) # DON'T remove this line
# 1663597, 2022-10-29 10:27:44, xxx-x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False

    for i in range(len(word)):
        if pattern[i]!='?' and word[i]!=pattern[i]:
            return False

    for i in range(len(word)):
        if pattern[i]=='?' and word[i] in exclude_chars:
            return False

    for i in range(len(word)):
        if pattern[i]=='?':
            index = include_chars.find(word[i])
            if index==-1:
                return False
            else:
                include_chars.pop(index)
    if len(incluce_chars)!=0:
        return False

    return True

exec(input()) # DON'T remove this line
# 1663782, 2022-10-29 10:31:20, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):return False

    for i in range(len(word)):
        if pattern[i]!='?' and word[i]!=pattern[i]:
            return False

    for i in range(len(word)):
        if pattern[i]=='?' and word[i] in exclude_chars:
            return False

    listpat=list(pattern)
    for c in include_chars:
        s=0
        for i in range(len(word)):
            if listpat[i]=='?' and word[i]==c:
                listpat[i]=c
                s+=1
                break
        if s==0:return False

    return True

exec(input()) # DON'T remove this line

6530053921
# 1662259, 2022-10-29 09:52:03, xP-Px (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    if len(word) != len(pattern) :
        out = False
    Include = ''
    for i in range(len(pattern)) :
        if pattern[i] != '?':
            if word[i] != pattern[i] :
                out = False
        elif pattern[i] == '?':
            Include = Include + word[i]
            if word[i] in exclude_chars :
                out = False
    for i in include_chars :
        if i not in Include :
            out = False
    return out
        
exec(input()) # DON'T remove this line
# 1663318, 2022-10-29 10:22:25, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    if len(word) != len(pattern) :
        out = False
    else :
        Include = ''
        for i in range(len(pattern)) :
            if pattern[i] != '?':
                if word[i] != pattern[i] :
                    out = False
            elif pattern[i] == '?':
                Include = Include + word[i]
                if word[i] in exclude_chars :
                    out = False
        for i in include_chars :
            if i in Include :
                pos = Include.find(i)
                Include = Include[:pos]+Include[pos+1:]
            if i not in Include :
                out = False
    return out
exec(input()) # DON'T remove this line

# 1663584, 2022-10-29 10:27:31, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    if len(word) != len(pattern) :
        out = False
    else :
        Include = ''
        for i in range(len(pattern)) :
            if pattern[i] != '?':
                if word[i] != pattern[i] :
                    out = False
            elif pattern[i] == '?':
                Include = Include + word[i]
                if word[i] in exclude_chars :
                    out = False
        for i in include_chars :
            if i in Include :
                pos = Include.find(i)
                Include = Include[:pos]+Include[pos+1:]
            elif i not in Include :
                out = False
    return out

exec(input()) # DON'T remove this line

6530075721
# 1662422, 2022-10-29 09:57:40, ----- (0%)

def match(w, pat, in_cha, ex_cha) :
    if len(w) != len(pat) : #first rule
        print('False')
        return
    for i in range(len(w)) : #second rule
        if pat[i] != '?' and w[i] != pat[i] :
            print('False')
            return 
    for i in range(len(w)) : #third rule
        if pat[i] == '?' and w[i] in ex_cha :
            print('False')
            return
    z = []
    for i in range(len(w)) : #forth rule
        if pat[i] == '?' :
            z.append(w[i])
    z.sort()
    in_cha = sorted([i for i in in_cha])
    if len(z) == len(in_cha) :
        for i in range(len(z)) :
            if z[i] != in_cha[i] :
                print('False')
                return
    elif in_cha != [] :
        for i in in_cha :
            if i not in z :
                print('False')
                return
    print('True')
    return 

exec(input())
# 1662462, 2022-10-29 09:58:41, ----- (0%)

def match(w, pat, in_cha, ex_cha) :
    if len(w) != len(pat) : #first rule
        x = False ; print(x)
        return
    for i in range(len(w)) : #second rule
        if pat[i] != '?' and w[i] != pat[i] :
            x = False ; print(x)
            return 
    for i in range(len(w)) : #third rule
        if pat[i] == '?' and w[i] in ex_cha :
            x = False ; print(x)
            return
    z = []
    for i in range(len(w)) : #forth rule
        if pat[i] == '?' :
            z.append(w[i])
    z.sort()
    in_cha = sorted([i for i in in_cha])
    if len(z) == len(in_cha) :
        for i in range(len(z)) :
            if z[i] != in_cha[i] :
                x = False ; print(x)
                return
    elif in_cha != [] :
        for i in in_cha :
            if i not in z :
                x = False ; print(x)
                return
    x = True ; print(x)
    return 

exec(input())

# 1662516, 2022-10-29 10:00:17, PPPPP (100%)

def match(w, pat, in_cha, ex_cha) :
    if len(w) != len(pat) : #first rule
        return False
    for i in range(len(w)) : #second rule
        if pat[i] != '?' and w[i] != pat[i] :
            return False
    for i in range(len(w)) : #third rule
        if pat[i] == '?' and w[i] in ex_cha :
            return False
    z = []
    for i in range(len(w)) : #forth rule
        if pat[i] == '?' :
            z.append(w[i])
    z.sort()
    in_cha = sorted([i for i in in_cha])
    if len(z) == len(in_cha) :
        for i in range(len(z)) :
            if z[i] != in_cha[i] :
                return False
    elif in_cha != [] :
        for i in in_cha :
            if i not in z :
                return False
    return True

exec(input())


6530099821
# 1662398, 2022-10-29 09:57:01, ----- (0%)

def match(w, p, ic, ec):
    a = []
    if len(w) == len(p):
        z = 0
        for i in range(len(p)):
            if p[i] == '?':
                a.append(w[i])
            elif p[i] != '?' and p[i] != w[i]:
                z = 1
                return False
            elif p[i] == '?' and w[i] in ec:
                z = 1
                return False
            
        if z == 0:
            for j in ic:
                if j not in a:
                    return False
                else:
                    a.remove(j)
            return True
    else:
        return False
# 1662427, 2022-10-29 09:57:46, PPP-- (60%)

def match(w, p, ic, ec):
    a = []
    if len(w) == len(p):
        z = 0
        for i in range(len(p)):
            if p[i] == '?':
                a.append(w[i])
            elif p[i] != '?' and p[i] != w[i]:
                z = 1
                return False
            elif p[i] == '?' and w[i] in ec:
                z = 1
                return False
            
        if z == 0:
            for j in ic:
                if j not in a:
                    return False
                else:
                    a.remove(j)
            return True
    else:
        return False

exec(input())
# 1662560, 2022-10-29 10:01:53, PPPPP (100%)

def match(w, p, ic, ec):
    a = []
    if len(w) == len(p):
        z = 0
        for i in range(len(p)):
            if p[i] != '?' and p[i] != w[i]:
                z = 1
                return False
            elif p[i] == '?' and w[i] in ec:
                z = 1
                return False
            elif p[i] == '?':
                a.append(w[i])
            
        if z == 0:
            for j in ic:
                if j not in a:
                    return False
                else:
                    a.remove(j)
            return True
    else:
        return False


exec(input())

6530103621
# 1662058, 2022-10-29 09:45:54, PPPPP (100%)

def  match(word, pattern, include_chars, exclude_chars):
    l = []
    if len(word) != len(pattern) : return False
    for i in range(len(word)):
        if pattern[i] != "?":
            if pattern[i] != word[i] : return False
        else:
            if word[i] in exclude_chars: return False
            l.append(word[i])
    for e in include_chars:
        if e not in l : return False
        a = include_chars.count(e)
        aa = str(l).count(e)
        if a > aa : return False
    return True
    
exec(input())
# 1662082, 2022-10-29 09:46:49, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
    l = []
    if len(word) != len(pattern) : return False
    for i in range(len(word)):
        if pattern[i] != "?":
            if pattern[i] != word[i] : return False
        else:
            if word[i] in exclude_chars: return False
            l.append(word[i])
    for e in include_chars:
        if e not in l : return False
        a = include_chars.count(e)
        aa = str(l).count(e)
        if a > aa : return False
    return True
    
#exec(input())
# 1662088, 2022-10-29 09:46:56, PPPPP (100%)

def  match(word, pattern, include_chars, exclude_chars):
    l = []
    if len(word) != len(pattern) : return False
    for i in range(len(word)):
        if pattern[i] != "?":
            if pattern[i] != word[i] : return False
        else:
            if word[i] in exclude_chars: return False
            l.append(word[i])
    for e in include_chars:
        if e not in l : return False
        a = include_chars.count(e)
        aa = str(l).count(e)
        if a > aa : return False
    return True
    
exec(input())

6530116821
# 1662137, 2022-10-29 09:48:34, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a=[]
    for i in word:
        a.append(i)
    b=[]
    for i in pattern:
        b.append(i)
    c=[]
    for i in include_chars:
        c.append(i)
    d=[]
    for i in exclude_chars:
        d.append(i)
    f=True
    if len(a)!=len(b):
        f=False
    else:
        for i in range(len(a)):
            if a[i]!=b[i]:
                if b[i]=='?':
                    if a[i] in c:
                        c.remove(a[i])
                    elif a[i] in d:
                        f=False
                else:
                    f=False
        if len(c)!=0:
            f=False
    return f
# 1662200, 2022-10-29 09:50:28, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a=[]
    for i in word:
        a.append(i)
    b=[]
    for i in pattern:
        b.append(i)
    c=[]
    for i in include_chars:
        c.append(i)
    d=[]
    for i in exclude_chars:
        d.append(i)
    f=True
    if len(a)!=len(b):
        f=False
    else:
        for i in range(len(a)):
            if a[i]!=b[i]:
                if b[i]=='?':
                    if a[i] in c:
                        c.remove(a[i])
                    elif a[i] in d:
                        f=False
                else:
                    f=False
        if len(c)!=0:
            f=False
    return print(f)
exec(input()) # DON'T remove this line

# 1662284, 2022-10-29 09:52:55, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    a=[]
    for i in word:
        a.append(i)
    b=[]
    for i in pattern:
        b.append(i)
    c=[]
    for i in include_chars:
        c.append(i)
    d=[]
    for i in exclude_chars:
        d.append(i)
    f=True
    if len(a)!=len(b):
        f=False
    else:
        for i in range(len(a)):
            if a[i]!=b[i]:
                if b[i]=='?':
                    if a[i] in c:
                        c.remove(a[i])
                    elif a[i] in d:
                        f=False
                else:
                    f=False
        if len(c)!=0:
            f=False
    return f
exec(input()) # DON'T remove this line


6530149521
# 1661818, 2022-10-29 09:38:11, xPxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    k = list(include_chars)
    if len(word) == len(pattern) :
        ch = True 
        for i in range ( len(word)) :
            if pattern[i] != '?' :
                if word[i] != pattern[i] :
                    ch = False
                    break
            else :
                if word[i] in exclude_chars :
                    ch = False
                    break
                if word[i] in include_chars :
                    k.pop(k.index(word[i]))
    if len(k) != 0 :
        ch = False
    return  ch
exec(input())
# 1661860, 2022-10-29 09:39:24, xPPPx (60%)

def match(word, pattern, include_chars, exclude_chars):
    k = list(include_chars)
    if len(word) == len(pattern) :
        ch = True 
        for i in range ( len(word)) :
            if pattern[i] != '?' :
                if word[i] != pattern[i] :
                    ch = False
                    break
            else :
                if word[i] in exclude_chars :
                    ch = False
                    break
                if word[i] in k :
                    k.pop(k.index(word[i]))
    if len(k) != 0 :
        ch = False
    return  ch
exec(input())
# 1661909, 2022-10-29 09:40:49, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    k = list(include_chars)
    ch = False
    if len(word) == len(pattern) :
        ch = True 
        for i in range ( len(word)) :
            if pattern[i] != '?' :
                if word[i] != pattern[i] :
                    ch = False
                    break
            else :
                if word[i] in exclude_chars :
                    ch = False
                    break
                if word[i] in k :
                    k.pop(k.index(word[i]))
    if len(k) != 0 :
        ch = False
    return  ch
exec(input())

6530151721
# 1661832, 2022-10-29 09:38:38, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not (pattern[i]=='?' or word[i]==pattern[i]):
            return False
    ex=[]
    for i in range(len(word)):
        if pattern[i]=='?':
            ex.append(word[i])
    for i in exclude_chars:
        if i in ex:
            return False
    inc=[]
    for i in range(len(word)):
    if pattern[i]=='?':
        inc.append(word[i])
    
    
    
    return  True
exec(input()) # DON'T remove this line


# 1661850, 2022-10-29 09:39:08, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not (pattern[i]=='?' or word[i]==pattern[i]):
            return False
    ex=[]
    for i in range(len(word)):
        if pattern[i]=='?':
            ex.append(word[i])
    for i in exclude_chars:
        if i in ex:
            return False
    inc=[]
    for i in range(len(word)):
      if pattern[i]=='?':
        inc.append(word[i])
    
    
    
    return  True
exec(input()) # DON'T remove this line
# 1662053, 2022-10-29 09:45:40, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not (pattern[i]=='?' or word[i]==pattern[i]):
            return False
    ex=[]
    for i in range(len(word)):
        if pattern[i]=='?':
            ex.append(word[i])
    for i in exclude_chars:
        if i in ex:
            return False
    inc=[]
    for i in range(len(word)):
        if pattern[i]=='?':
            inc.append(word[i])
    for i in include_chars:
        if i not in inc:
            return False
        else:
            inc.remove(i)   
    return  True
exec(input()) # DON'T remove this line

6531310321
# 1661754, 2022-10-29 09:35:22, PP--- (40%)

def match(word,pattern,include_chars,exclude_chars):
    chck=[]
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]=='?':
            chck.append(word[i])
            continue
        elif pattern[i]!=word[i] or word[i] in exclude_chars:
            return False
    for j in range(len(include_chars)):
        if include_chars[j] not in chck:
            return False
    return True
exec(input())
# 1661880, 2022-10-29 09:39:47, PPP-- (60%)

def match(word,pattern,include_chars,exclude_chars):
    chck=[]
    if len(word)!=len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i]=='?':
                chck.append(word[i])
                continue
            elif pattern[i]!=word[i] or word[i] in exclude_chars:
                return False
    lenchar=len(include_chars)
    for j in range(lenchar):
        if include_chars[j] not in chck:
            return False
        chck.remove(include_chars[j])    
    return True
exec(input())
# 1663155, 2022-10-29 10:18:28, PPPPP (100%)

def match(word,pattern,include_chars,exclude_chars):
    chck=[]
    if len(word)!=len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i]=='?':
                chck.append(word[i])
                continue
            elif pattern[i]!=word[i]:
                return False
        for j in range(len(chck)):
            if chck[j] in exclude_chars:
                return False 
    lenchar=len(include_chars)
    if lenchar==0:
        return True
    for j in range(lenchar):
        if include_chars[j] not in chck:
            return False
        chck.remove(include_chars[j])    
    return True
exec(input())

6531314921
# 1661866, 2022-10-29 09:39:32, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    a = []
    e = []
    b = 0
    for i in range(len(pattern)):
        if len(pattern) == len(word):
            if pattern[i] != "?":
                if pattern[i] != word[i]:
                    b = b+1
            else:
                e.append(word[i])
        else:
            b = b+1
    c = word
    d = []
    for j in include_chars:
        if c.find(j) != -1:
            d.append(c.find(j))
            c = c[0:c.find(j)]+" "+c[c.find(j)+1:]
        else:
            b = b+1
    for k in exclude_chars:
        if i in e:
            b = b+1
    if b == 0:
        return True
    else:
        return False

exec(input())
# 1662034, 2022-10-29 09:45:12, PPP-- (60%)

def match(word, pattern, include_chars, exclude_chars):
    a = []
    e = []
    f = e
    b = 0
    for i in range(len(pattern)):
        if len(pattern) == len(word):
            if pattern[i] != "?":
                if pattern[i] != word[i]:
                    b = b+1
            else:
                e.append(word[i])
        else:
            b = b+1
    c = word
    d = []
    for j in include_chars:
        if j in f:
            f.remove(j)
        else:
            b = b+1
    for k in exclude_chars:
        if i in e:
            b = b+1
    if b == 0:
        return True
    else:
        return False



exec(input())
# 1662155, 2022-10-29 09:49:16, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    a = []
    e = []
    f = e
    b = 0
    for i in range(len(pattern)):
        if len(pattern) == len(word):
            if pattern[i] != "?":
                if pattern[i] != word[i]:
                    b = b+1
            else:
                e.append(word[i])
        else:
            b = b+1
    c = word
    d = []
    for j in include_chars:
        if j in f:
            f.remove(j)
        else:
            b = b+1
    for k in exclude_chars:
        if k in e:
            b = b+1
    if b == 0:
        return True
    else:
        return False



exec(input())

6531322921
# 1662115, 2022-10-29 09:47:52, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == "?":
            continue
        if word[i] != pattern[i]:
            return False
    q = ""
    for j in range(len(word)):
        if pattern[j] == "?":
            q += word[j]
    for p in q:
        if p in exclude_chars:
            return False
    qlist = []
    inlist = []
    for r in q:
        qlist.append(r)
    for k in include_chars:
        inlist.append(k)
    qlist.sort()
    inlist.sort()
    if qlist != inlist:
        return False
    return True
exec(input())
# 1662609, 2022-10-29 10:03:16, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == "?":
            continue
        if word[i] != pattern[i]:
            return False
    q = ""
    for j in range(len(word)):
        if pattern[j] == "?":
            q += word[j]
    for p in q:
        if p in exclude_chars:
            return False
    inlist = []
    for k in include_chars:
        inlist.append(k)
    for r in q:
        inlist.remove(r)
    if inlist != []:
        return False
    return True
exec(input())
# 1662624, 2022-10-29 10:03:47, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == "?":
            continue
        if word[i] != pattern[i]:
            return False
    q = ""
    for j in range(len(word)):
        if pattern[j] == "?":
            q += word[j]
    for p in q:
        if p in exclude_chars:
            return False
    inlist = []
    for k in include_chars:
        inlist.append(k)
    for r in q:
        try:
            inlist.remove(r)
        except:
            pass
    if inlist != []:
        return False
    return True
exec(input())

6532043021
# 1662197, 2022-10-29 09:50:25, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    mark=[]
    if(len(word)!=len(pattern)):
        return False
    
    for i in range(len(word)):
        if(pattern[i]=='?'):
            mark.append(word[i])
            continue
        if(word[i]!=pattern[i]):
            return False

    for e in exclude_chars:
        if e in mark:
            return False

    for e in include_chars:
        ch=0
        for i in range(len(ch)):
            if(mark[i]==e):
                mark.pop(i)
                ch=1
        if not ch:
            return False
    return True
    
        

            

exec(input())
# 1662236, 2022-10-29 09:51:27, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    mark=[]
    if(len(word)!=len(pattern)):
        return False
    
    for i in range(len(word)):
        if(pattern[i]=='?'):
            mark.append(word[i])
            continue
        if(word[i]!=pattern[i]):
            return False

    for e in exclude_chars:
        if e in mark:
            return False

    for e in include_chars:
        ch=0
        for i in range(len(mark)):
            if(mark[i]==e):
                mark.pop(i)
                ch=1
        if not ch:
            return False
    return True
            
exec(input())

#print(match("MACMA", "M?C??", "MAA", ""))
# 1662276, 2022-10-29 09:52:39, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    mark=[]
    if(len(word)!=len(pattern)):
        return False
    
    for i in range(len(word)):
        if(pattern[i]=='?'):
            mark.append(word[i])
            continue
        if(word[i]!=pattern[i]):
            return False

    for e in exclude_chars:
        if e in mark:
            return False

    for e in include_chars:
        ch=0
        for i in range(len(mark)):
            if(mark[i]==e):
                mark.pop(i)
                ch=1
                break
        if not ch:
            return False
    return True
            
exec(input())

#print(match("MACMA", "M?C??", "MAA", ""))

6532182521
# 1661936, 2022-10-29 09:41:47, xxxxx (0%)

from cv2 import sort


def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if (pattern[i] != '?' and pattern[i] != word[i]) or (pattern[i] == '?' and word[i] in exclude_chars):
            return False

    for w in include_chars:
        cnti = include_chars.count(w)
        cntw = word.count(w)
        if cnti > cntw:
            return False
        if w not in word:
            return False

    return True


exec(input())  # DON'T remove this line

# 1661944, 2022-10-29 09:42:04, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if (pattern[i] != '?' and pattern[i] != word[i]) or (pattern[i] == '?' and word[i] in exclude_chars):
            return False

    for w in include_chars:
        cnti = include_chars.count(w)
        cntw = word.count(w)
        if cnti > cntw:
            return False
        if w not in word:
            return False

    return True


exec(input())  # DON'T remove this line

# 1661982, 2022-10-29 09:43:22, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    myw = ""
    for i in range(len(word)):
        if pattern[i] == '?':
            myw += word[i]
        if (pattern[i] != '?' and pattern[i] != word[i]) or (pattern[i] == '?' and word[i] in exclude_chars):
            return False

    for w in include_chars:
        cnti = include_chars.count(w)
        cntw = myw.count(w)
        if cnti > cntw:
            return False
        if w not in myw:
            return False

    return True


exec(input())  # DON'T remove this line


6532186021
# 1662064, 2022-10-29 09:46:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    index = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == '?':
            index.append(i)
            continue
        if pattern[i] != word[i]:
            return False
    for e in index:
        if word[e] in exclude_chars:
            return False
    include_chars = list(include_chars)
    for e in index:
        if word[e] in include_chars:
            include_chars.remove(word[e])
    if include_chars == []:
        return False
    return True
# 1662077, 2022-10-29 09:46:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    index = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == '?':
            index.append(i)
            continue
        if pattern[i] != word[i]:
            return False
    for e in index:
        if word[e] in exclude_chars:
            return False
    include_chars = list(include_chars)
    for e in index:
        if word[e] in include_chars:
            include_chars.remove(word[e])
    if include_chars == []:
        return False
    return True
    
exec(input())
# 1662150, 2022-10-29 09:49:08, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    index = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == '?':
            index.append(i)
            continue
        if pattern[i] != word[i]:
            return False
    for e in index:
        if word[e] in exclude_chars:
            return False
    include_chars = list(include_chars)
    for e in index:
        if word[e] in include_chars:
            include_chars.remove(word[e])
    if include_chars != []:
        return False
    return True
    
exec(input())

6530003521
# 1662017, 2022-10-29 09:44:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    inc.extend(include_chars)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
        elif pattern[i] == '?' and word[i] in exclude_chars :
            return False
        elif pattern[i] == '?' and word[i] in  inc :
            j = inc.index(word[i])
            inc.pop(j)
    if inc != [] :
        return False
    else : return True
            
# 1662050, 2022-10-29 09:45:35, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    inc.extend(include_chars)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
        elif pattern[i] == '?' and word[i] in exclude_chars :
            return False
        elif pattern[i] == '?' and word[i] in  inc :
            j = inc.index(word[i])
            inc.pop(j)
    if inc != [] :
        return False
    else : return True
exec(input())

6530007021
# 1661780, 2022-10-29 09:36:14, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    re = True
    check = ''
    if len(word) != len(pattern):
        re = False
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            re = False
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            check += word[i]
    for i in check:
        if i in exclude_chars:
            re = False
            return False
    for i in include_chars:
        if i not in word:
            re = False
            return False
    return True
exec(input()) # DON'T remove this line

# 1662193, 2022-10-29 09:50:22, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    re = True
    check = ''
    lis = []
    if len(word) != len(pattern):
        re = False
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            re = False
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            check += word[i]
    for i in check:
        if i in exclude_chars:
            re = False
            return False
    for i in check:
        lis.append(i)
    for i in include_chars:
        if i not in lis:
            re = False
            return False
        else :
            lis.remove(i)
    return True
exec(input()) # DON'T remove this line

6530012121
# 1662774, 2022-10-29 10:08:38, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    ans = 'True'
    if len(word) != len(pattern):
        ans = 'False'
        return print(ans)
    for i in range(len(word)):
        if not(pattern[i] == '?' or pattern[i].upper() == word[i].upper()):
            ans = 'False'
            return print(ans)
            break
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                ans = 'False'
                return print(ans)
                break
    kkk = []
    for i in range(len(word)):
        if pattern[i] == '?':
            kkk.append(word[i])
    for k in range(len(include_chars)):
        if include_chars[k] not in kkk:
            ans = "False"
            return print(ans)
            break
        else:
            kkk.remove(include_chars[k])
    return print(ans)
        
exec(input()) # DON'T remove this line

# 1662825, 2022-10-29 10:09:45, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    ans = True
    if len(word) != len(pattern):
        ans = False
        return ans
    for i in range(len(word)):
        if not(pattern[i] == '?' or pattern[i].upper() == word[i].upper()):
            ans = False
            return ans
            break
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                ans = False
                return ans
                break
    kkk = []
    for i in range(len(word)):
        if pattern[i] == '?':
            kkk.append(word[i])
    for k in range(len(include_chars)):
        if include_chars[k] not in kkk:
            ans = False
            return ans
            break
        else:
            kkk.remove(include_chars[k])
    return ans
        
exec(input()) # DON'T remove this line


6530014421
# 1662761, 2022-10-29 10:08:14, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    x=include_chars
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]=='?':
            if word[i] in exclude_chars:
                return False
        elif pattern[i]==word[i]:
            pass
        else:
            return False
    for i in range(len(word)):
        if pattern[i]=='?':
            k=x.find(word[i])
            if k!=-1:
                x=x[:k]+x[k+1:]
            if len(x)==0:
                return True                
    if len(x)!=0:
        return False
    return True
print(match("MACMA", "M?C??", "MAA", ""))
print(match("MACMA", "M?C??", "AM", ""))
print(match("MACMA", "M?C??", "", "") )
print(match("MACMA", "M?C??", "", "CPE"))
print(match("MACMA", "?????", "AAMM", "OK"))
print(match("MACMA", "MACMA", "", "MACMA"))
print('------')
print(match("MACMA", "M?C??", "AAA", ""))
print(match("MACMA", "M?C??", "MAX", "") )
print(match("MACMA", "M?C??", "C", ""))
print(match("MACMA", "M?C??", "", "MX"))
print(match("MACMA", "M?C???", "", ""))
print(match("MACMA", "M?C?", "", ""))
exec(input()) # DON'T remove this line

# 1662777, 2022-10-29 10:08:40, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    x=include_chars
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]=='?':
            if word[i] in exclude_chars:
                return False
        elif pattern[i]==word[i]:
            pass
        else:
            return False
    for i in range(len(word)):
        if pattern[i]=='?':
            k=x.find(word[i])
            if k!=-1:
                x=x[:k]+x[k+1:]
            if len(x)==0:
                return True                
    if len(x)!=0:
        return False
    return True

exec(input()) # DON'T remove this line

6531403021
# 1662391, 2022-10-29 09:56:44, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range (len(word)) :
        if word[i]!=pattern[i] and pattern[i]!='?' :
            return False
        if word[i]!=pattern[i] and pattern[i]=='?' :
            if word[i] in exclude_chars :
                return False
    j = -1
    for i in range (len(include_chars)) :
        if include_chars[i-1] != include_chars[i] :
            j=-1
        j = word.find(include_chars[i],j+1)
        if j == -1 or pattern[j]!='?' :
            return False
        
    return True

exec(input()) # DON'T remove this line

# 1662629, 2022-10-29 10:04:02, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    x = []
    if len(word) != len(pattern) :
        return False
    for i in range (len(word)) :
        if word[i]!=pattern[i] and pattern[i]!='?' :
            return False
        if word[i]!=pattern[i] and pattern[i]=='?' :
            x.append(i)
            if word[i] in exclude_chars :
                return False
    j = -1
    for i in range (len(include_chars)) :
        if include_chars[i-1] != include_chars[i] :
            j=-1
        j = word.find(include_chars[i],j+1)
        if pattern[j]!='?' or j==-1:
            j = word.find(include_chars[i],j+1)
        if j == -1  :
            return False
        if not j in x :
            return False
        x.remove(j)
        
    return True


exec(input()) # DON'T remove this line


6530049421
# 1661813, 2022-10-29 09:38:00, PPPPP (100%)

#QUIZ 2 p2
def  match(word, pattern, include_chars, exclude_chars) :
    list_include = list(include_chars)
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?':
            return False
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            if word[i] in list_include:
                list_include.remove(word[i])
    if len(list_include) != 0:
        return False
    return True


exec(input()) # DON'T remove this line




# 1663635, 2022-10-29 10:28:28, PPPPP (100%)

#QUIZ 2 p2
def  match(word, pattern, include_chars, exclude_chars) :
    list_include = list(include_chars)
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?':
            return False
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            if word[i] in list_include:
                list_include.remove(word[i])
    if len(list_include) != 0:
        return False
    return True


exec(input()) # DON'T remove this line

# Code by Kanisorn P.

6530059721
# 1662449, 2022-10-29 09:58:19, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        dic_in = {}
        for ch in include_chars:
            if ch in dic_in:
                dic_in[ch] += 1
            else:
                dic_in[ch] = 1
                
        dic_ans = {}
        for i in range(len(word)):
            if pattern[i]!=word[i]:
                if pattern[i] == "?":
                    if word[i] in dic_ans:
                        dic_ans[word[i]] += 1
                    else:
                        dic_ans[word[i]] = 1
                else:
                    return False
            
        for ch in dic_ans:
            if dic_in!={}:
                if ch in dic_in:
                    if dic_in[ch]>dic_ans[ch]:
                        return False
            if ch in exclude_chars:
                return False
        return True
                
exec(input()) # DON'T remove this line

# 1662525, 2022-10-29 10:00:41, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        dic_in = {}
        for ch in include_chars:
            if ch in dic_in:
                dic_in[ch] += 1
            else:
                dic_in[ch] = 1
                
        dic_ans = {}
        for i in range(len(word)):
            if pattern[i]!=word[i]:
                if pattern[i] == "?":
                    if word[i] in dic_ans:
                        dic_ans[word[i]] += 1
                    else:
                        dic_ans[word[i]] = 1
                else:
                    return False
            
        for ch in dic_ans:
            if dic_in!={}:
                if ch in dic_in:
                    if dic_in[ch]>dic_ans[ch]:
                        return False
            if ch in exclude_chars:
                return False
        for ch in dic_in:
            if ch not in dic_ans:
                return False
        return True
                
exec(input()) # DON'T remove this line


6530085021
# 1662383, 2022-10-29 09:56:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    p = True
    s = ""
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != "?":
                if pattern[i] != word[i]:
                    p = False
            else:
                s += word[i]
        for n in s:
            if n in exclude_chars:
                p = False
            elif n in include_chars:
                include_chars = include_chars.replace(n,"",1)
        if include_chars != "":
            p =False
    else:
        p = False
    return p
# 1662410, 2022-10-29 09:57:17, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    p = True
    s = ""
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != "?":
                if pattern[i] != word[i]:
                    p = False
            else:
                s += word[i]
        for n in s:
            if n in exclude_chars:
                p = False
            elif n in include_chars:
                include_chars = include_chars.replace(n,"",1)
        if include_chars != "":
            p =False
    else:
        p = False
    return p
exec(input()) 

6530113921
# 1662252, 2022-10-29 09:51:48, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    q = []
    co = 0
    for i in range(len(pattern)):
        if pattern[i] == '?':
            q.append(i)
        else:
            co += 1
    if len(word) != len(pattern):
        return False
    count = 0
    for i in range(len(word)):
        if word[i] == pattern[i]:
            count += 1
    if count != co:
        return False
    c = []
    for i in range(len(q)):
        if word[q[i]] in exclude_chars:
            return False
        c.append(word[q[i]])
    for i in include_chars:
        if i not in c:
            return False
    return True

exec(input())

# 1662394, 2022-10-29 09:56:50, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    q = []
    co = 0
    for i in range(len(pattern)):
        if pattern[i] == '?':
            q.append(i)
        else:
            co += 1
    if len(word) != len(pattern):
        return False
    count = 0
    for i in range(len(word)):
        if word[i] == pattern[i]:
            count += 1
    if count != co:
        return False
    c = []
    for i in range(len(q)):
        if word[q[i]] in exclude_chars:
            return False
        c.append(word[q[i]])
    for i in include_chars:
        if i not in c:
            return False
        else:
            c.remove(i)
    return True

exec(input())


6530141421
# 1662385, 2022-10-29 09:56:34, PP-P- (60%)

def match(word,pattern,include_chars,exclude_chars):
    undif = []
    check = 0
    if len(pattern) != len(word):
        return False
    for i in range(len(word)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        elif pattern[i] == "?":
            if word[i] not in undif:
                undif.append(word[i])
    for e in undif:
        if e in exclude_chars:
            return False
    for e in include_chars:
        if e not in undif:
            return False
        else:
            undif.remove(e)
    return True
exec(input()) # DON'T remove this line
# 1662478, 2022-10-29 09:59:08, PPPPP (100%)

def match(word,pattern,include_chars,exclude_chars):
    undif = []
    x = []
    check = 0
    if len(pattern) != len(word):
        return False
    for i in range(len(word)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        elif pattern[i] == "?":
            if word[i] not in undif:
                undif.append(word[i])
            x.append(word[i])
            
    for e in undif:
        if e in exclude_chars:
            return False
    for e in include_chars:
        if e not in x:
            return False
        else:
            x.remove(e)
    return True
exec(input()) # DON'T remove this line

6530163221
# 1662262, 2022-10-29 09:52:12, xPPPx (60%)

def match(word, pattern, include_chars, exclude_chars):
    one = len(word) == len(pattern)
    inc = []
    for i in include_chars:
        inc += [i]
    check = 0
    checkk = 0
    N = 0
    
    for i in range(len(pattern)):
        if pattern[i] == '?':
            check += 1
            checkk += 1
            if word[i] in exclude_chars:
                pass
            else:
                N +=1
            if word[i] in inc:
                inc.remove(word[i])
                
        elif pattern[i] == word[i]:
            check +=1 
        
    if check == len(pattern):
        second = True
    else:
        second = False
        
    if N == checkk:
        third = True
    else:
        third = False
    
    if inc == []:
        foul = True
    else:
        foul = False
    
    return( one and second and third and foul )
    
exec(input()) # DON'T remove this line

# 1662557, 2022-10-29 10:01:44, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    one = len(word) == len(pattern)
    inc = []
    for i in include_chars:
        inc += [i]
    check = 0
    checkk = 0
    N = 0
    
    for i in range(len(pattern)):
        if len(pattern) > len(word):
            break
        if pattern[i] == '?':
            check += 1
            checkk += 1
            if word[i] in exclude_chars:
                pass
            else:
                N +=1
            if word[i] in inc:
                inc.remove(word[i])
                
        elif pattern[i] == word[i]:
            check +=1 
        
    if check == len(pattern):
        second = True
    else:
        second = False
        
    if N == checkk:
        third = True
    else:
        third = False
    
    if inc == []:
        foul = True
    else:
        foul = False
    
    return (one and second and third and foul)

exec(input()) # DON'T remove this line

6530166121
# 1662356, 2022-10-29 09:55:23, -PPP- (60%)

def match(word, pattern, include_chars, exclude_chars):
    is_match = True; qm = []
    if len(word) == len(pattern): #lens are equal
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]: #check '?'
                is_match = False
                break
            elif pattern[i] == '?':
                qm.append(word[i])
        for c in exclude_chars:
            if c in qm:
                is_match = False
                break
        for c in include_chars:
            if c in qm:
                qm.remove(c)
            else:
                is_match = False
                break
    return is_match
            
exec(input())            

# 1662417, 2022-10-29 09:57:29, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    is_match = True; qm = []
    if len(word) == len(pattern): #lens are equal
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]: #check '?'
                is_match = False
                break
            elif pattern[i] == '?':
                qm.append(word[i])
        for c in exclude_chars:
            if c in qm:
                is_match = False
                break
        for c in include_chars:
            if c in qm:
                qm.remove(c)
            else:
                is_match = False
                break
    else:
        is_match = False
    return is_match
            
exec(input())            


6530170621
# 1661994, 2022-10-29 09:43:51, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!='?' and\
           pattern[i]!=word[i]:
            return False
    k1=0
    for i in range(len(word)):
        k2=pattern.find('?',k1)
        if word[k2] in exclude_chars:
            return False
        k1+=1
        
        
        
    return True   
exec(input())
# 1662372, 2022-10-29 09:55:53, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!='?' and\
           pattern[i]!=word[i]:
            return False
    k1=0
    while True:
        k2=pattern.find('?',k1)
        if k2==-1:
            break
        if word[k2] in exclude_chars:
            return False
        k1=k2+1
    check=[]
    k1=0
    for i in range(len(pattern)):
        k2=pattern.find('?',k1)
        if k2==-1:
            break
        check.append(word[k2])
        k1=k2+1
    for e in include_chars:
        if e in check:
            check.remove(e)
        else:
            return False 
    return True   
exec(input())

6530173521
# 1663651, 2022-10-29 10:28:51, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    sen = []
    d = {}
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if word[i] == pattern[i]:
            pass
        elif pattern[i] == '?':
            sen.append(i)
            if word[i] in d:
                d[word[i]] += 1
            else:
                d[word[i]] = 1
        else:
            return False
    check = ''
    for i in sen:
        check += word[i]
    for i in check:
        if i in include_chars:
            d[i] -= 1
            if d[i] < 0:
                return False
        elif include_chars == '':
            pass
        else:
            return False
    for i in check:
        if i not in exclude_chars:
            pass
        elif exclude_chars == '':
            pass        
        else:
            return False    
    return True
exec(input())
# 1663916, 2022-10-29 10:33:46, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    sen = []
    d = {}
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if word[i] == pattern[i]:
            pass
        elif pattern[i] == '?':
            sen.append(i)
            if word[i] in d:
                d[word[i]] += 1
            else:
                d[word[i]] = 1
        else:
            return False
    check = ''
    for i in sen:
        check += word[i]
    for i in include_chars:
        if i in check:
            d[i] -= 1
            if d[i] < 0:
                return False
        elif include_chars == '':
            pass
        else:
            return False
    for i in exclude_chars:
        if i not in check:
            pass
        elif exclude_chars == '':
            pass        
        else:
            return False    
    return True
exec(input())

6530183821
# 1662416, 2022-10-29 09:57:26, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    s=''
    t=True
    if len(pattern)!=len(word):
        return False
    else:
        for i in range(len(pattern)):
            if pattern[i]!='?':
                if word[i]==pattern[i]:
                    t=True
                else:
                    return False
            else:
                s+=word[i]
        for e in include_chars:
            if e in s:
                pass
            else:
                return False
    
        for e in exclude_chars:
            if e in s:
                return False
    return t
exec(input())
# 1662796, 2022-10-29 10:08:58, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    s=''
    t=True
    if len(pattern)!=len(word):
        return False
    else:
        for i in range(len(pattern)):
            if pattern[i]!='?':
                if word[i]==pattern[i]:
                    t=True
                else:
                    return False
            else:
                s+=word[i]
        
        for e in include_chars:
            if e in s:
                pass
            else:
                return False
        ds={}
        dinclude_chars={}
        for e in s:
            if e in ds:
                ds[e]+=1
            else:
                ds[e]=1
        for e in include_chars:
            if e in dinclude_chars:
                dinclude_chars[e]+=1
            else:
                dinclude_chars[e]=1
            
        for e in dinclude_chars:
            
            if dinclude_chars[e]>ds[e]:
                return False
        for e in exclude_chars:
            if e in s:
                return False
    return t
exec(input())

6530195321
# 1662453, 2022-10-29 09:58:26, -PPP- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        c = 0
        you_nai_mark = []
        for i in range(len(pattern)):
            if pattern[i] != '?': 
                if word[i] == pattern[i]:
                    c+=1
                    
                else:
                    pass
            else:
                c+=1
                you_nai_mark.append(word[i])
        x = ''.join(you_nai_mark)
        count = 0
        if c == len(pattern):
            for e in you_nai_mark:
                if e in exclude_chars:
                    return False
                else:
                    pass
            for i in range(len(include_chars)):
                if include_chars[i] in you_nai_mark:
                    you_nai_mark.remove(include_chars[i])
                    count += 1
            if count != len(include_chars):
                return False
        else:
            return False
    
    return True
                    


            
exec(input()) # DON'T remove this line
# 1662597, 2022-10-29 10:03:01, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        c = 0
        you_nai_mark = []
        for i in range(len(pattern)):
            if pattern[i] != '?': 
                if word[i] == pattern[i]:
                    c+=1
                    
                else:
                    pass
            else:
                c+=1
                you_nai_mark.append(word[i])
        x = ''.join(you_nai_mark)
        count = 0
        if c == len(pattern):
            for e in you_nai_mark:
                if e in exclude_chars:
                    return False
                else:
                    pass
            for i in range(len(include_chars)):
                if include_chars[i] in you_nai_mark:
                    you_nai_mark.remove(include_chars[i])
                    count += 1
            if count != len(include_chars):
                return False
        else:
            return False
    else:
        return False
    return True


exec(input()) # DON'T remove this line

6530204321
# 1663647, 2022-10-29 10:28:43, P--P- (40%)

def checkword(word,pattern):
    d=[]
    if len(word)!=len(pattern):
        return [False]
    else:
        for i in range(len(word)):
            if pattern[i] == '?':
                d.append(word[i])
            if word[i] != pattern[i] and pattern[i] != '?':
                return [False]
    return [True,d]
def checkex(x,exclude_chars):
    for i in x:
        if i in exclude_chars:
            return False
    return True
def checkin(x,include_chars):
    if len(include_chars)==0:
        return True
    check=[]
    numcheck=[]
    print(x,include_chars)
    for i in include_chars:
        if i not in x:
            return False
        else:
            if i not in check:
                numcheck.append(x.count(i))
                check.append(i)
    for i in range(len(check)):
        if numcheck[i] < include_chars.count(check[i]):
            return False
    return True
def match(word,pattern,include_chars,exclude_chars):
    check=checkword(word,pattern)
    if check[0]==False:
        return False
    else:
        check,x=checkword(word,pattern)
        if checkin(x,include_chars)!=True:
            return False
        else:
            if checkex(x,exclude_chars) != True:
                return False
    return True
exec(input())
        

# 1663678, 2022-10-29 10:29:25, PPPPP (100%)

def checkword(word,pattern):
    d=[]
    if len(word)!=len(pattern):
        return [False]
    else:
        for i in range(len(word)):
            if pattern[i] == '?':
                d.append(word[i])
            if word[i] != pattern[i] and pattern[i] != '?':
                return [False]
    return [True,d]
def checkex(x,exclude_chars):
    for i in x:
        if i in exclude_chars:
            return False
    return True
def checkin(x,include_chars):
    if len(include_chars)==0:
        return True
    check=[]
    numcheck=[]
    for i in include_chars:
        if i not in x:
            return False
        else:
            if i not in check:
                numcheck.append(x.count(i))
                check.append(i)
    for i in range(len(check)):
        if numcheck[i] < include_chars.count(check[i]):
            return False
    return True
def match(word,pattern,include_chars,exclude_chars):
    check=checkword(word,pattern)
    if check[0]==False:
        return False
    else:
        check,x=checkword(word,pattern)
        if checkin(x,include_chars)!=True:
            return False
        else:
            if checkex(x,exclude_chars) != True:
                return False
    return True
exec(input())
        


6531339621
# 1661883, 2022-10-29 09:39:55, PPPPP (100%)

from xml.etree.ElementInclude import include


def match(word, pattern, include_chars, exclude_chars):
    wordbin = []
    if(len(pattern) != len(word)):
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            wordbin.append(word[i])
        if(pattern[i] != '?' and word[i] != pattern[i]):
            return False
    # check for excluded characters
    for e in exclude_chars:
        if e in wordbin:
            return False
    # check for included characters
    for i in include_chars:
        if i not in wordbin:
            return False
        else:
            wordbin.remove(i)
    return True


def test():
    print(match("MACMA", "M?C??", "MAA", ""))
    print(match("MACMA", "M?C??", "AM", ""))
    print(match("MACMA", "M?C??", "", ""))
    print(match("MACMA", "M?C??", "", "CPE"))
    print(match("MACMA", "?????", "AAMM", "OK"))
    print(match("MACMA", "MACMA", "", "MACMA"))
    print(match("MACMA", "M?C??", "AAA", ""))
    print(match("MACMA", "M?C??", "MAX", ""))
    print(match("MACMA", "M?C??", "C", ""))
    print(match("MACMA", "M?C??", "", "MX"))
    print(match("MACMA", "M?C???", "", ""))
    print(match("MACMA", "M?C?", "", ""))


exec(input())

# 1661890, 2022-10-29 09:40:09, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    wordbin = []
    if(len(pattern) != len(word)):
        return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            wordbin.append(word[i])
        if(pattern[i] != '?' and word[i] != pattern[i]):
            return False
    # check for excluded characters
    for e in exclude_chars:
        if e in wordbin:
            return False
    # check for included characters
    for i in include_chars:
        if i not in wordbin:
            return False
        else:
            wordbin.remove(i)
    return True


def test():
    print(match("MACMA", "M?C??", "MAA", ""))
    print(match("MACMA", "M?C??", "AM", ""))
    print(match("MACMA", "M?C??", "", ""))
    print(match("MACMA", "M?C??", "", "CPE"))
    print(match("MACMA", "?????", "AAMM", "OK"))
    print(match("MACMA", "MACMA", "", "MACMA"))
    print(match("MACMA", "M?C??", "AAA", ""))
    print(match("MACMA", "M?C??", "MAX", ""))
    print(match("MACMA", "M?C??", "C", ""))
    print(match("MACMA", "M?C??", "", "MX"))
    print(match("MACMA", "M?C???", "", ""))
    print(match("MACMA", "M?C?", "", ""))


exec(input())

6531341821
# 1662750, 2022-10-29 10:07:50, PPP-- (60%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    d=0
    exc=[]
    inc=[]
    inc2=[]
    inc3=[]
    inc4=[]
    inc5=[]
    for i in include_chars:
        if i not in inc:
            inc2.append([i,include_chars.count(i)])
            inc.append([i])
    inc2.sort()
    for i in exclude_chars:
        exc.append([i])
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if 'A'<=pattern[i]<='Z':
            if word[i]!=pattern[i]:
                return False
        elif pattern[i]=='?':
            if word[i] in exc:
                return False
            else:
                inc5.append(word[i])

    for i in inc2:
        if i[1]>inc5.count(i[0]):
            return False

    return True
    
    
exec(input()) # DON'T remove this line

# 1662882, 2022-10-29 10:11:28, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    d=0
    exc=[]
    inc=[]
    inc2=[]
    inc3=[]
    inc4=[]
    inc5=[]
    for i in include_chars:
        if i not in inc:
            inc2.append([i,include_chars.count(i)])
            inc.append([i])
    inc2.sort()
    for i in exclude_chars:
        exc.append(i)
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if 'A'<=pattern[i]<='Z':
            if word[i]!=pattern[i]:
                return False
        elif pattern[i]=='?':
        
            if word[i] in exc:
                return False
            else:
                inc5.append(word[i])

    for i in inc2:
        if i[1]>inc5.count(i[0]):
            return False

    return True
    
    
exec(input()) # DON'T remove this line


6532054921
# 1661803, 2022-10-29 09:37:39, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word) != len(pattern)) :
        return False

    cu = ""
    for i in range(len(word)) :
        if(pattern != "?") :
            if(word[i] != pattern[i]) :
                return True
        else :
            cu += word[i]
    for j in exclude_chars :
        if(j in cu) :
            return False
    for k in include_chars :
        if cu.find(k) == -1 :
            return False
        else :
            cu = cu[0:cu.find(k)] + cu[cu.find(k) + 1:]       
exec(input()) # DON'T remove this line
# 1661990, 2022-10-29 09:43:43, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word) != len(pattern)) :
        return False

    cu = ""
    for i in range(len(word)) :
        if(pattern[i] != "?") :
            if(word[i] != pattern[i]) :
                return False
        else :
            cu += word[i]
    for j in exclude_chars :
        if(j in cu) :
            return False
    for k in include_chars :
        if cu.find(k) == -1 :
            return False
        else :
            cu = cu[0:cu.find(k)] + cu[cu.find(k) + 1:]    
    return True   
exec(input()) # DON'T remove this line

6532084721
# 1661825, 2022-10-29 09:38:20, -PPPP (80%)


def match(word,pattern,in_ch,ex_ch):
    if len(pattern)!=len(word): 
        return False
    cnt = dict()
    uk = dict()
    for i in range(len(pattern)):
        if pattern[i] =='?':
            if word[i] not in uk: uk[word[i]] = 1
            else:                 uk[word[i]]+= 1

    for i in in_ch:
        if i not in cnt:
            cnt[i] = 1
        else: cnt[i] += 1

    for i in cnt:
        if i not in uk or (i in uk and cnt[i]>uk[i]):
            return False

    for i in uk:
        if i in ex_ch:
            return False

    return True

exec(input())
# 1661914, 2022-10-29 09:40:56, PPPPP (100%)

def match(word,pattern,in_ch,ex_ch):
    if len(pattern)!=len(word): 
        return False
    cnt = dict()
    uk = dict()
    for i in range(len(pattern)):
        if pattern[i] =='?':
            if word[i] not in uk: uk[word[i]] = 1
            else:                 uk[word[i]]+= 1
        else:
            if pattern[i]!=word[i]: return False

    for i in in_ch:
        if i not in cnt:
            cnt[i] = 1
        else: cnt[i] += 1

    for i in cnt:
        if i not in uk or (i in uk and cnt[i]>uk[i]):
            return False

    for i in uk:
        if i in ex_ch:
            return False

    return True

exec(input())

6532092721
# 1661654, 2022-10-29 09:30:49, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if (len(word) != len(pattern)) : return False
    dic = {}
    for i in range(len(word)) :
        if word[i] != pattern[i] : return False
        if pattern[i] == "?" :
            if word[i] in exclude_chars : return False
            dic[word[i]] = 1
    for c in include_chars :
        if c not in dic :
            return False
    return True


exec(input()) # DON'T remove this line
# 1661796, 2022-10-29 09:37:17, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if (len(word) != len(pattern)) : return False
    dic = {}
    for i in range(len(word)) :
        if pattern[i] == "?" :
            if word[i] in exclude_chars : return False
            if (word[i] not in dic) :
                dic[word[i]] = 1
            else :
                dic[word[i]] += 1
        elif word[i] != pattern[i] : return False
    for c in include_chars :
        if (c not in dic) or (dic[c] == 0):
            return False
        dic[c] -= 1
    return True


exec(input()) # DON'T remove this line

6532114921
# 1661895, 2022-10-29 09:40:15, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False

    ck = True
    for i in range(len(word)):
        if pattern[i] == '?': 
            if word[i] in exclude_chars: ck = False
            continue
        if word[i] != pattern[i]: 
            ck = False
            break
    if not ck: return False

    for e in include_chars:
        ind = word.find(e)
        if ind == -1: return False
        word = word[:ind] + word[ind+1:]
    return True

exec(input())
# 1661988, 2022-10-29 09:43:39, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False

    ck = True
    temp = ''
    for i in range(len(word)):
        if pattern[i] == '?': 
            if word[i] in exclude_chars: ck = False
            temp += word[i]
            continue
        if word[i] != pattern[i]: 
            ck = False
            break
    if not ck: return False

    for e in include_chars:
        ind = temp.find(e)
        if ind == -1: return False
        temp = temp[:ind] + temp[ind+1:]
    return True

exec(input())

6532143021
# 1662210, 2022-10-29 09:50:41, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    s = ''
    d = {}
    d2 = {}
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            # print('1')
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            # print('2')
            return False
        if pattern[i] == '?' and word[i] not in exclude_chars:
            s += word[i]
    
    for i in s:
        if i not in d:
            d[i] = 1
        else:
            d[i] += 1
    
    for i in include_chars:
        if i not in d2:
            d2[i] = 1
        else:
            d2[i] += 1
    # print(d)
    # print(d2)
    for i in d2:
        if d2[i] > d[i]:
            # print('3')
            return False

    return True

exec(input())

    
# print(match("MACMA", "M?C??", "AAA", ""))
# 1662239, 2022-10-29 09:51:35, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    s = ''
    d = {}
    d2 = {}
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            # print('1')
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            # print('2')
            return False
        if pattern[i] == '?' and word[i] not in exclude_chars:
            s += word[i]
    
    for i in s:
        if i not in d:
            d[i] = 1
        else:
            d[i] += 1
    
    for i in include_chars:
        if i not in d2:
            d2[i] = 1
        else:
            d2[i] += 1
    # print(d)
    # print(d2)
    for i in d2:
        if i not in d or d2[i] > d[i]:
            # print('3')
            return False

    return True

exec(input())

    
# print(match("MACMA", "M?C??", "AAA", ""))

6330148721
# 1664328, 2022-10-29 10:39:09, PPPPP (100%)

from operator import truediv


def match(word, pattern, include_chars, exclude_chars):
    if(len(word) == len(pattern)): 
        x = True
        for i in range(len(word)):
            if(pattern[i] != "?" and pattern[i] != word[i]):
                x = False
                break
        if(x):
            for i in range(len(word)):
                y = True
                if(pattern[i] == "?" and word[i] in exclude_chars):
                    y = False
                    break
            if(y):
                z = ""
                for i in range(len(word)):
                    if(pattern[i] == "?"):
                        z += word[i]
                for e in include_chars:
                    if(z.find(e) != -1):
                        if(z.find(e) != len(z)-1):
                            z = z[:z.find(e)] + z[z.find(e) + 1:]
                        else:
                            z = z[:z.find(e)]
                    else:
                        return False
                return True
            else:
                return False
        else:
            return False
    else:
        return False

exec(input())

6530015021
# 1661725, 2022-10-29 09:33:39, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    #word = upper letter ONLY!!!
    #check len
    
    if len(word) != len(pattern):
        return False
    
    #check pattern
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    
    #check include_chars
    check = list(include_chars)
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in check:
            check.remove(word[i])
    if len(check) != 0:
        return False
    
    #check exclude_chars
    ex = list(exclude_chars)
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in ex:
            return False
        
    return True
    
exec(input()) # DON'T remove this line


6530072821
# 1661740, 2022-10-29 09:34:40, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    anything = []
    for i in range(len(pattern)):
        if pattern[i] !="?":
            if pattern[i]!=word[i]: return False
        else:
            anything.append(i)
    whatever = []
    for i in anything:
        if word[i] in exclude_chars: return False
        whatever.append(word[i])
    for ch in include_chars:
        if ch not in whatever: return False
        whatever.pop(whatever.index(ch))
        
    return True
    
exec(input()) # DON'T remove this line


6530077021
# 1662075, 2022-10-29 09:46:26, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    index = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            #print('a')
            return False
            break
        elif pattern[i] == '?' and word[i] in exclude_chars:
            #print('b')
            return False
            break
        if pattern[i] == '?':
            index.append(word[i])
        
    for m in include_chars:
        if m not in index and m != '':
            #print('c')
            return False
            break
        else :
            index.remove(m)
        
    return True

            
    
exec(input()) 

6530078621
# 1662539, 2022-10-29 10:01:05, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        a=[]
        for i in range(len(pattern)):
            if pattern[i]=='?' or pattern[i]==word[i]: pass
            elif pattern[i]!=word[i]: return False
        for i in range(len(pattern)):
            if pattern[i]=='?':
                if word[i] in exclude_chars: return False
                else: a.append(word[i])
        for i in range(len(include_chars)):
            if include_chars[i] in a:
                a.pop(a.index(include_chars[i]))
            else: return False
        return True
    else: return False

exec(input())

6530083721
# 1662175, 2022-10-29 09:49:49, PPPPP (100%)

def match(w, p, inc, e):
    temp = []
    if len(w) != len(p):
        return False
    for k in range(len(p)):
        if p[k] == '?':
            temp += w[k]
        else:
            if p[k] != w[k]: return False
    for i in temp:
        if i in e: return False
    for i in inc:
        if i in temp:
            temp.remove(i)
        else: return False
    return True 
exec(input()) # DON'T remove this line


6530117421
# 1661637, 2022-10-29 09:30:15, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    l = []
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != "?" and pattern[i] != word[i]: return False
            if pattern[i] == "?" and word[i] in exclude_chars: return False
            if pattern[i] == "?": l.append(word[i])
        for i in include_chars: inc.append(i)
        for i in l:
            if i in inc: inc.remove(i)
        if len(inc) != 0: return False
        return True
    else: return False
            
    
exec(input()) # DON'T remove this line


6530162621
# 1661650, 2022-10-29 09:30:47, PPPPP (100%)

# 2565_1_Quiz_2_2

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        questionPattern = []
        for i in range(len(word)):
            if pattern[i] == '?':
                questionPattern.append(word[i])
            elif pattern[i] != word[i]:
                return False
            
        for e in exclude_chars:
            if e in questionPattern:
                return False
            
        for e in include_chars:
            if e in questionPattern:
                questionPattern.remove(e)
            else:
                return False
        
        return True

    else:
        return False
    
exec(input())


6530177021
# 1662680, 2022-10-29 10:05:34, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    R = True
    ALP = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
    checkq1 = []
    for a in word:
        if a not in ALP:
            R = False
            break
    #condition1
    if len(word) != len(pattern):
        R = False
    else:
        #condition2
        for a2 in range(len(pattern)):
            if pattern[a2] != '?' and pattern[a2] not in word[a2]:
                R = False
                break
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checkq1 += [word[i]]
        checkq2 = checkq1
        #condition3
        xc = list(exclude_chars)
        for m in checkq1:
            if m in xc:
                R = False
        #conditoin4
        ic = list(include_chars)
        for p in ic:
            if p in checkq2:
                checkq2.remove(p)
            else:
                R = False
    return R
exec(input())


6530181521
# 1661753, 2022-10-29 09:35:22, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    l = []
    for i in range(len(word)) :
        if word[i] == pattern[i] :
            pass
        elif pattern[i] == '?' :
            l.append(word[i])
        else :
            return False
    for i in exclude_chars :
        if i in l :
            return False
    for i in include_chars :
        if i in l :
            l.remove(i)
        else :
            return False
    return True

exec(input())

6530187321
# 1661814, 2022-10-29 09:38:01, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    d = []
    x = []
    for i in range(len(pattern)):
        if 'A' <= pattern[i] <= 'Z': d.append(i)
        else: x.append(i)
    for e in d:
        if word[e] != pattern[e]: return False
    for e in x:
        if word[e] in exclude_chars: return False
    a = []
    for e in x:
        a += word[e]
    for e in include_chars:
        if e in a: a.remove(e)
        else: return False
    return True
    
            
exec(input())


6530197621
# 1661862, 2022-10-29 09:39:28, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    ans = True
    question = []
    if len(word) != len(pattern):
        ans = False
    else:
        for i in range(len(word)):
            if pattern[i] != "?":
                if pattern[i] != word[i]:
                    ans = False
            else:
                if word[i] in exclude_chars:
                    ans = False
                question.append(word[i])
    for e in include_chars:
        if e not in question:
            ans = False
            break
        else:
            idx = question.index(e)
            question = question[0:idx]+question[idx+1:]
    return ans

exec(input()) 

6530209521
# 1662554, 2022-10-29 10:01:32, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    def is_pat(word,key) :
        bools = True
        for c in range(len(word)) :
            if key[c] != '?' and key[c] != word[c] :
                bools = False
            break
        return bools
    
    def noexcc(w,pat,exc) :
        bools = True
        for i in range(len(pat)) :
            if pat[i] == '?' :
                if w[i] in exc :
                    bools = False
        return bools
                
    def incc(w,pat,inc) :
        bools = True
        wo = ''
        for y in range(len(pat)) :
            if pat[y] == '?' :
                wo += w[y]
        for x in inc :
            if x not in wo :
                bools = False
            else :
                q = []
                for zz in wo :
                    q.append(zz)
                q.remove(x)
                wo = ''.join(q)
        return bools
                    
    if len(word) == len(pattern) :
        if is_pat(word,pattern) == True :
            if noexcc(word,pattern,exclude_chars) == True :
                if incc(word,pattern,include_chars) == True :
                    return True
                else :
                    return False
            else :
                return False
        else :
            return False
    else :
        return False

exec(input()) # DON'T remove this line


6530212321
# 1662071, 2022-10-29 09:46:15, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    
    check_index = [] #"M?C??" "MACMA"
    check_q = []
    for i in range(len(pattern)) :
        if pattern[i] != '?' :
            check_index.append(i)
        else :
            check_q.append(i)
    for i in check_index :
        if word.upper()[i] != pattern.upper()[i] :
            return False
    
    include = []
    for i in check_q :
        if word[i] in exclude_chars :
            return False
        else :
            include.append(word.upper()[i])
    
    includechars = list(include_chars.upper())
    include.sort()
    includechars.sort()
    
    for e in includechars :
        if e not in include :
            return False
    if len(includechars) == len(include) :
        if include != includechars :
            return False

    return True

exec(input()) # DON'T remove this line

6531303021
# 1662028, 2022-10-29 09:45:05, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern):return False
       
    for e in range(len(word)):
        if word[e] != pattern[e] and pattern[e] !='?':return False;break

    s = []
    for e in range(len(word)):
            if pattern[e] =='?':s.append(e)
    for d in s:
        if word[d] in exclude_chars:return False
    
    z = [word[i] for i in s]
    if len(z) < len(include_chars):return False
    for i in include_chars:
        if i in z:
            z.remove(i)
        else: return False
    return True

    
exec(input())

6531304621
# 1662220, 2022-10-29 09:51:02, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    d = {}
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                if word[i] in d:
                    d[word[i]] += 1
                else:
                    d[word[i]] = 1
            elif pattern[i] == word[i]:
                pass
            else:
                return False
        for ch in exclude_chars:
            if ch in d:
                return False
        for ch in include_chars:
            if ch not in d:
                return False
            else:
                d[ch] -= 1
                if d[ch] < 0:
                    return False
        return True
    else:
        return False

exec(input()) # DON'T remove this line

6531309821
# 1661660, 2022-10-29 09:31:00, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    included = []

    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != "?":
            return False
        if pattern[i] == "?" and word[i] in exclude_chars:
            return False
        if pattern[i] == "?":
            included.append(word[i])
    for i in include_chars:
        if i not in included:
            return False
        else:
            included.remove(i)
    
    return True

exec(input())

6531312621
# 1662130, 2022-10-29 09:48:24, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for i in range(len(pattern)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    note = []
    for i in range(len(pattern)):
        if pattern[i] == '?':
            note.append(word[i])
    for e in include_chars:
        if e not in note:
            return False
        elif e in note:
            note.remove(e)
    return True

exec(input())

6531316121
# 1662015, 2022-10-29 09:44:31, PPPPP (100%)

def first(word,pattern):
    if len(word) == len(pattern):
        return True
    return False

def second(word,pattern):
    for i in range(len(word)):
        if pattern[i] != "?":
            if word[i] != pattern[i]:
                return False
    return True

def third(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    return True

def fourth(word,pattern,include_chars):
    wordlist = []
    for i in range(len(word)):
        if pattern[i] == "?":
            wordlist.append(word[i])
    for e in include_chars:
        if e in wordlist:
            wordlist.remove(e)
        else:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if first(word,pattern) and second(word,pattern) \
        and third(word,pattern,exclude_chars) and fourth(word,pattern,include_chars):
        return True
    return False

exec(input())


6531320621
# 1662684, 2022-10-29 10:05:39, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    for i in range(len(pattern)):
        if pattern[i] == word[i] and pattern[i] != '?':
            pass
        elif pattern[i] == '?':
            continue
        else:
            return False

    missing = []
    for i in range(len(pattern)):
        if pattern[i] == '?':
            missing.append(word[i])

    for i in missing:
        if i in exclude_chars:
            return False
    missing_dict = dict()
    include_dict = dict()
    for i in missing:
        if i not in missing_dict:
            missing_dict[i] = 1
        else:
            missing_dict[i] += 1
    for i in include_chars:
        if i not in include_dict:
            include_dict[i] = 1
        else:
            include_dict[i] += 1
    
    for i in include_dict.keys():
        if i in missing_dict:
            missing_dict[i] -= include_dict[i]
        else:
            return False

    for i in missing_dict.values():
        if i < 0:
            return False

    return True
exec(input()) # DON'T remove this line

6531323521
# 1662484, 2022-10-29 09:59:16, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        check = []
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != "?" :
                return False 
            elif pattern[i] == "?" :
                if word[i] in exclude_chars :
                    return False
                else :
                    check.append(word[i])
        for i in include_chars :
            if i in check :
                check.remove(i)
            else :
                return False
        return True
    return False 










 

exec(input()) # DON'T remove this line

6531329321
# 1661869, 2022-10-29 09:39:34, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    x = []
    if len(word) != len(pattern): return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
        if pattern[i] =='?' :
            x.append(word[i])
    if not include_chars == '':
        for e in include_chars:
            if e in x:
                x.remove(e)
            else:
                return False
    return True
exec(input())

6531333821
# 1661636, 2022-10-29 09:30:14, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if (len(word) != len(pattern)):
        return False
    mysteryList = []
    for i in range(len(word)):
        if (pattern[i] != '?'):
            if pattern[i] != word[i]:
                return False
        else:
            mysteryList.append(word[i])
    for c in exclude_chars:
        if c in mysteryList:
            return False
    for c in include_chars:
        if c in mysteryList:
            mysteryList.remove(c)
        else:
            return False
    return True


exec(input())

6531334421
# 1663164, 2022-10-29 10:18:47, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern): return False
    else:
        check = []
        for i in range(len(word)):
            if pattern[i]!=word[i]:
                if pattern[i]!='?': return False
                elif word[i] in list(exclude_chars): return False
                else:
                    check.append(word[i])
    
    for i in list(include_chars):
        if i in check:
            check.remove(i)
        else: return False
    
    return True

exec(input()) # DON'T remove this line

6531337321
# 1661808, 2022-10-29 09:37:47, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False

    include_chars = list(include_chars)
    for a, b in zip(word, pattern):
        if b == '?':
            if a in exclude_chars:
                return False
            elif a in include_chars:
                include_chars.remove(a)
        elif a != b:
            return False
    
    if include_chars:
        return False
    return True

exec(input())

6531340121
# 1661830, 2022-10-29 09:38:26, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    x = len(pattern)
    y = pattern.count('?')
    
    if len(word) != len(pattern):
        return False
    else:
        n = 0
        for i in range(len(word)):
            if word[i] == pattern[i]:
                n += 1
        l = []
        for i in range(len(pattern)):
            if pattern[i] == "?":
                l.append(i)
        if n != x-y:
            return False
        for e in l:
            if word[e] in exclude_chars:
                return False
        l1 = [word[i] for i in l]
        for i in range(len(include_chars)):
            if include_chars[i] in l1:
                l1.remove(include_chars[i])
            else:
                return False
        return True

exec(input())

6531345321
# 1661877, 2022-10-29 09:39:42, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    lw = len(word)
    lp = len(pattern)
    if lp != lw :
        return False 
    else :
        for i in range(lw) :
            if word[i] != pattern[i] and pattern[i] != '?' : # test pattern of both
                return False 
        temp = ''
        for i in range(lp) : # test exclude char
            if pattern[i] == '?' :
                temp += word[i]
                if word[i] in exclude_chars :
                    return False
        # test include _char 
        ts = [e for e in temp]
        for e in include_chars:
            if e not in ts :
                return False 
            else :
                ts.remove(e)
        return True




#print(match("MACMA", "M?C??", "C", ""))

exec(input()) # DON'T remove this line

6531346021
# 1661894, 2022-10-29 09:40:14, PPPPP (100%)



def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        ch=True
        l1=[]
        l2=[]
        for i in range(len(pattern)):
            if pattern[i]!='?':
                l1.append(word[i])
                if pattern[i]!=word[i]:
                    ch=False
            else:
                l2.append(word[i])
        #print(l1,l2,ch)
        if ch==False:
            return False
        
        for i in exclude_chars:
            if i in l2:
                #print('x')
                return False
        for i in include_chars:
            if i not in l2:
        
                #print('y')
                return False
            l2.pop(l2.index(i))
        return True


exec(input()) # DON'T remove this line

6532011921
# 1661487, 2022-10-29 09:25:53, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False

    required = {}
    for i in range(len(include_chars)):
        required[include_chars[i]] = required.get(include_chars[i], 0) + 1

    for i in range(len(pattern)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
            if word[i] in include_chars:
                required[word[i]] -= 1
        else:
            if word[i] != pattern[i]:
                return False

    for k in required:
        if required[k] > 0:
            return False
    return True

exec(input()) 

6532026321
# 1661562, 2022-10-29 09:28:10, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) != len(pattern): return False
  inc = []
  for i, v in enumerate(word):
    if pattern[i] == '?':
      inc.append(v)
    else:
      if pattern[i] != v:
        return False
  for i in exclude_chars:
    if i in inc:
      return False
  for i in include_chars:
    if i not in inc:
      return False
    else:
      inc.remove(i)
  return True

exec(input())


6532027021
# 1661466, 2022-10-29 09:25:20, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    
    cnt1 = [0] * 26
    cnt2 = [0] * 26
    for c in include_chars :
        cnt1[ord(c) - 65] += 1

    n = len(word)
    for i in range(n) :
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
            cnt2[ord(word[i]) - 65] += 1
        elif word[i] != pattern[i] :
                return False
    
    for i in range(26) :
        if cnt1[i] > cnt2[i] :
            return False
    return True

exec(input()) # DON'T remove this line

6532035021
# 1662196, 2022-10-29 09:50:25, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    q = ''
    for i in range(len(word)):
        if pattern[i] == '?':q += word[i]
        elif word[i] != pattern[i]: return False
    if any([x for x in exclude_chars if x in q]):return False
    for x in include_chars:
        if q.count(x) < include_chars.count(x):return False
    return True

exec(input()) # DON'T remove this line

6532068721
# 1661471, 2022-10-29 09:25:32, PPPPP (100%)

def check_pattern(word: str, pattern: str):
    if len(word) != len(pattern):
        return (False, [])

    used_in_pattern = []

    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] == '?':
                used_in_pattern.append(word[i])
            else:
                return (False, [])

    return [True, used_in_pattern]


def match(word: str, pattern: str, include_chars: str, exclude_chars: str):
    ok, used_in_pattern = check_pattern(word, pattern)

    if not ok:
        return False

    used_map = {}

    for used in used_in_pattern:
        if used in exclude_chars:
            return False
        used_map[used] = used_map.get(used, 0) + 1

    for inc in include_chars:
        if used_map.get(inc, 0) <= 0:
            return False
        used_map[inc] -= 1

    return True


exec(input())  # DON'T remove this line


6532082421
# 1662441, 2022-10-29 09:58:14, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if (len(word) != len(pattern)):
        return False
    tmp = ''
    for i in range(len(word)):
        if (pattern[i] != '?'):
            if (word[i] != pattern[i]):
                return False
        else:
            if (word[i] in exclude_chars):
                return False
            tmp += word[i]
    tmp = sorted(tmp)
    include_chars = sorted(include_chars)
    for i in include_chars:
        if (not (i in tmp)):
            return False
        else:
            tmp.remove(i)
    return True


exec(input())  # DON'T remove this line


6532123521
# 1661579, 2022-10-29 09:28:29, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word) != len(pattern)):
        return False
    include_chars = list(include_chars)
    for i in range(len(word)):
        if(pattern[i] != '?'):
            if(pattern[i] != word[i]):
                return False
        if(pattern[i] == '?'):
            if(word[i] in exclude_chars):
                return False
            elif(word[i] in include_chars):
                include_chars.remove(word[i])
    if(len(include_chars) > 0):
        return False
    return True


exec(input())


6532148221
# 1662424, 2022-10-29 09:57:41, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False

    add = []
    for i in range(0, len(word)):
        if pattern[i] == '?':
            add += [word[i]]
            continue
        if word[i] != pattern[i]:
            return False
    
    for k in add:
        if k in exclude_chars:
            return False

    for k in include_chars:
        if k in add:
            add.pop( add.index(k) )
        else:
            return False
    
    return True

exec( input() ) # DON'T remove this line

6532152721
# 1661794, 2022-10-29 09:37:08, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != "?":
            return False
    blank = ""
    for i in range(len(word)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
            blank += word[i]

    include_chars = sorted(include_chars)
    blank = sorted(blank)

    for i in range(len(include_chars)):
        if include_chars[i] not in blank:
            return False
        else:
            blank.remove(include_chars[i])

    return True


exec(input()) # DON'T remove this line

6532155621
# 1661817, 2022-10-29 09:38:10, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != "?":
            return False
    for i in range(len(word)):
        if pattern[i] == "?" and word[i] in exclude_chars:
            return False
    for ic in include_chars:
        rep = False
        newPattern = pattern
        for i in range(len(word)):
            if pattern[i] == "?" and word[i] == ic:
                rep = True
                newPattern = pattern[: i] + word[i] + pattern[i+1: ]
        pattern = newPattern
        if not rep: return False

    # print("Should return True")
    return True

exec(input()) # DON'T remove this line
# print(exec(input())) # DON'T remove this line


6532157921
# 1661807, 2022-10-29 09:37:43, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        # print('F')
        return False
    for i,j in zip(word,pattern):
        if j!='?' and i!=j:
            # print('F')
            return False
        if j=='?' and (i in exclude_chars):
            # print('F')
            return False
        if j=='?':
            idx = include_chars.find(i)
            if idx != -1:
                include_chars=include_chars[:idx]+include_chars[idx+1:]
    if include_chars=="":
        # print('T')
        return True
    # print('F')
    return False

exec(input())


6532187721
# 1661724, 2022-10-29 09:33:39, PPPPP (100%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern): return False
    A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    L = [0]*26
    l = [0]*26
    p=1
    for i in range(len(word)):
        if pattern[i]=='?':
            L[A.find(word[i])]+=1
        else:
            if pattern[i]!=word[i]: p=0
    if p==0: return False
    for x in include_chars:
        l[A.find(x)]+=1
    for i in range(len(L)):
        if l[i]>L[i]: return False
    for x in exclude_chars:
        if L[A.find(x)]!=0: return False
    return True 

exec(input())

6531801121
# 1662589, 2022-10-29 10:02:45, PPPPP (100%)

def check_exclude(lst, s):
    for c in s:
        if c in lst:
            return False
    return True

def check_include(lst, s):
    char_lst = list()
    amount = list()
    cop_lst = list(lst)
    for c in s:
        char_lst.append(c)
    for char in char_lst:
        if char in lst:
            if char in cop_lst:
                cop_lst.remove(char)
            else:
                return False
        else: return False
    return True       
         
def match(word, pattern, include_chars, exclude_chars):
    is_match = True
    if len(word) == len(pattern):
        fixed = list()
        qm_lst = list()
        for i in range(len(word)):
            if pattern[i] == "?":
                qm_lst.append(word[i])
            elif word[i] != pattern[i]:
                is_match = False
                return is_match
            elif word[i] == pattern[i]:
                fixed.append(word[i])
        is_match = check_exclude(qm_lst, exclude_chars)
        if is_match:
            is_match = check_include(qm_lst, include_chars)
            return is_match
        else:
            return is_match
    else:
        is_match = False
        return is_match

exec(input())

6531805721
# 1662393, 2022-10-29 09:56:49, PPPPP (100%)

def match_pattern(a,b): # a = pattern , b = word
    if len(a) == len(b):
        for i in range(len(a)):
            if a[i] != b[i] and a[i] != '?':
                return False
        return True
    else:
        return False



def check_include_char(w,b,p): # w = word , b = include_char , p = pattern
    c= {}
    for i in b:
        if i not in c:
            c[i] = 1
        else:
            c[i] += 1
    
    for i in range(len(p)):
        if p[i] == '?':
            if w[i] in c:
                c[w[i]] -= 1
            
    
    for i in c:
        if c[i] > 0:
            return False
    return True

def check_exclude_char(w,e,p): # w = word , e = exclude_char , p = pattern
    for i in range(len(p)):
        if p[i] == '?':
            if w[i] in e:
                return False
    return True

def match(word,pattern,include_chars,exclude_chars):
    if not match_pattern(pattern,word):
        return False
    if not check_exclude_char(word,exclude_chars,pattern):
        return False
    if not check_include_char(word,include_chars,pattern):
        return False
    return True
        
        
    
exec(input().strip())

Max Score = 80


6530207221
# 1662278, 2022-10-29 09:52:45, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if  l == l2 :
            pass
        else :
            out = False
    return out
            
exec(input()) # DON'T remove this line
# 1662315, 2022-10-29 09:54:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if  l == l2 :
            pass
        else :
            out = False
    return print(out)
            
exec(input()) # DON'T remove this line
# 1662439, 2022-10-29 09:58:13, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        for i in range(len(l)):
            if l[i] in l2:
                pass
            else :
                out = False
    return out
            
exec(input()) # DON'T remove this line
# 1662871, 2022-10-29 10:11:05, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if len(l2) == len(l):
            if l1 == l2 :
                pass
            else :
                out = False
        else :
            if len(l2) < len(l):
                for i in range(len(l2)):
                    if l2[i] in l :
                        pass
                    else :
                        out = False
    return out
            
exec(input()) # DON'T remove this line
# 1662893, 2022-10-29 10:11:53, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if len(l2) == len(l):
            if l1 == l2 :
                pass
            else :
                out = False
        else :
            if len(l2) < len(l):
                for i in range(len(l2)):
                    if l2[i] in l :
                        pass
                    else :
                        out = False
    return out
            
exec(input()) # DON'T remove this line
# 1662937, 2022-10-29 10:13:02, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if len(l2) == len(l):
            if l == l2 :
                pass
            else :
                out = False
        else :
            if len(l2) < len(l):
                for i in range(len(l2)):
                    if l2[i] in l :
                        pass
                    else :
                        out = False
    return out
            
exec(input()) # DON'T remove this line
# 1663018, 2022-10-29 10:15:04, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if len(l2) == len(l):
            if l == l2 :
                pass
            else :
                out = False
        else :
            if len(l2) < len(l):
                for i in range(len(l2)):
                    if l2[i] in l :
                        pass
                    else :
                        out = False
    return out
            
exec(input()) # DON'T remove this line
# 1663079, 2022-10-29 10:16:17, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if len(l2) == len(l):
            if l == l2 :
                pass
            else :
                out = False
        else :
            if len(l2) < len(l):
                for i in range(len(l2)):
                    if l2[i] in l :
                        pass
                    else :
                        out = False
    return out
            
exec(input()) # DON'T remove this line
# 1663095, 2022-10-29 10:16:38, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if len(l2) == len(l):
            if l == l2 :
                pass
            else :
                out = False
        else :
            if len(l2) < len(l):
                for i in range(len(l2)):
                    if l2[i] in l :
                        pass
                    else :
                        out = False
            else :
                for i in range(l):
                    if l[i] in l2:
                        pass
                    else :
                        out = False
    return out
            
exec(input()) # DON'T remove this line
# 1663270, 2022-10-29 10:21:17, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for ch in include_chars:
            l2.append(ch)
        l2.sort()
        if len(l2) == len(l):
            if l == l2 :
                pass
            else :
                out = False
        else :
            if len(l2) < len(l):
                for i in range(len(l2)):
                    if l2[i] in l :
                        pass
                    else :
                        out = False
    return out
            
exec(input()) # DON'T remove this line
# 1664404, 2022-10-29 10:39:53, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for i in range(include_chars):
            l2.append(include_chars[i])
        l2.sort()
        if len(l) == len(l2):
            if l == l2 :
                pass
            else :
                out = False
        else :
            for i in range(len(l2)):
                if l2[i] in l :
                    pass
                else :
                    out = False
    return out
            
exec(input()) # DON'T remove this line
# 1664504, 2022-10-29 10:40:41, PPPP- (80%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for i in range(len(include_chars)):
            l2.append(include_chars[i])
        l2.sort()
        if len(l) == len(l2):
            if l == l2 :
                pass
            else :
                out = False
        else :
            for i in range(len(l2)):
                if l2[i] in l :
                    pass
                else :
                    out = False
    return out
            
exec(input()) # DON'T remove this line
# 1664568, 2022-10-29 10:41:08, PPPP- (80%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    count = 0
    l = []
    l2 = []
    if len(word) != len(pattern):
        out = False
    else :
        for i in range(len(word)):
            if pattern[i] == '?' :
                if word[i] in exclude_chars:
                    out = False
                else :
                    pass
                if word[i] in include_chars:
                    l.append(word[i])
                else :
                    pass
            else :
                if word[i] != pattern[i]:
                    out = False
                else :
                    pass
        l.sort()
        for i in range(len(include_chars)):
            l2.append(include_chars[i])
        l2.sort()
        if len(l) == len(l2):
            if l == l2 :
                pass
            else :
                out = False
        else :
            for i in range(len(l2)):
                if l2[i] in l :
                    pass
                else :
                    out = False
    return out
            
exec(input()) # DON'T remove this line

6530178721
# 1662418, 2022-10-29 09:57:30, P--xx (20%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            if word[i] == pattern[i]:
                
                for d in exclude_chars:
                    if d in word[i]:
                        check = False
                    
                    else:   
                        countw = {} # {'M':1,'A':2}
                        for b in indq:
                            if word[b] in count:
                                count[word[b]] += 1
                            else:
                                count[word[b]] = 1
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] < countw[f]:
                                    check = False
                        for g in countw:
                            if g not in countin:
                                check = False
                
            else:
                check = False
    else:
        check = False
        
    return check

exec(input()) # DON'T remove this line

# 1662650, 2022-10-29 10:04:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            if word[i] == pattern[i]:
                
                for g in indq:
                    g = int(g)
                    for d in exclude_chars:
                        if d in word[g]:
                            check = False
                        
                        else:   
                            countw = {} # {'M':1,'A':2}
                            for b in indq:
                                b = int(b)
                                if word[b] in countw:
                                    countw[word[b]] += 1
                                else:
                                    countw[word[b]] = 1
                            for f in countin:
                                if f not in countw:
                                    check = False
                                else:
                                    if countin[f] < countw[f]:
                                        check = False

                
            else:
                check = False
    else:
        check = False
        
    print(check)
#    return check

exec(input()) # DON'T remove this line

# 1662902, 2022-10-29 10:12:07, ---xx (0%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            for h in indq:
                h = int(h)
                if word[i] == pattern[i]:
                    
                    for d in exclude_chars:
                        if d in word[h]:
                            check = False
                        
                        else:   
                            countw = {} # {'M':1,'A':2}
                            for b in indq:
                                b = int(b)
                                if word[b] in count:
                                    count[word[b]] += 1
                                else:
                                    count[word[b]] = 1
                            for f in countin:
                                if f not in countw:
                                    check = False
                                else:
                                    if countin[f] < countw[f]:
                                        check = False
                            for g in countw:
                                if g not in countin:
                                    check = False
                
            else:
                check = False
    else:
        check = False
        
    return check

exec(input()) # DON'T remove this line

# 1662920, 2022-10-29 10:12:41, ---xx (0%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            for h in indq:
                h = int(h)
                if word[i] == pattern[i]:
                    
                    for d in exclude_chars:
                        if d in word[h]:
                            check = False
                        
                        else:   
                            countw = {} # {'M':1,'A':2}
                            for b in indq:
                                b = int(b)
                                if word[b] in count:
                                    countw[word[b]] += 1
                                else:
                                    countw[word[b]] = 1
                            for f in countin:
                                if f not in countw:
                                    check = False
                                else:
                                    if countin[f] < countw[f]:
                                        check = False
                            for g in countw:
                                if g not in countin:
                                    check = False
                
            else:
                check = False
    else:
        check = False
        
    return check

exec(input()) # DON'T remove this line

# 1663190, 2022-10-29 10:19:19, ---x- (0%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    exclude_chars += ' '
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            for h in indq:
                h = int(h)
                if word[i] == pattern[i]:
                    
                    for d in exclude_chars:
                        if d in word[h]:
                            check = False
                        
                        else:   
                            countw = {} # {'M':1,'A':2}

                            if word[h] in countw:
                                countw[word[h]] += 1
                            else:
                                countw[word[h]] = 1
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] > countw[f]:
                                    check = False
                        for g in countw:
                            if g not in countin:
                                check = False
                
            else:
                check = False
    else:
        check = False
    
    print(check)
    return check

exec(input()) # DON'T remove this line

# 1663471, 2022-10-29 10:25:26, P--xx (20%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            if word[i] == pattern[i]:
                
                for d in exclude_chars:
                    if d in word[i]:
                        check = False
                    
                    else:   
                        countw = {} # {'M':1,'A':2}
                        for b in indq:
                            if word[b] in count:
                                count[word[b]] += 1
                            else:
                                count[word[b]] = 1
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] < countw[f]:
                                    check = False
                        for g in countw:
                            if g not in countin:
                                check = False
                
            else:
                check = False
    else:
        check = False
        
    return check

exec(input()) # DON'T remove this line
# 1663555, 2022-10-29 10:26:59, ---x- (0%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    exclude_chars += ' '
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            for h in indq:
                h = int(h)
                if word[i] == pattern[i]:
                    
                    for d in exclude_chars:
                        if d in word[h]:
                            check = False
                        
                        else:   
                            countw = {} # {'M':1,'A':2}

                            if word[h] in countw:
                                countw[word[h]] += 1
                            else:
                                countw[word[h]] = 1
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] > countw[f]:
                                    check = False
                        for g in countw:
                            if g not in countin:
                                check = False
                
            else:
                check = False
    else:
        check = False
    
    return check

exec(input()) # DON'T remove this line
# 1663695, 2022-10-29 10:29:44, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    exclude_chars += ' '
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
            
    countw = {} # {'M':1,'A':2}match("MACMA", "M?C??", "MAA", "")
    
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
            a = int(a)
            if word[a] in countw:
                countw[word[a]] += 1
            else:
                countw[word[a]] = 1
    
    countw = {} # {'M':1,'A':2}
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            for h in indq:
                h = int(h)
                if word[i] == pattern[i]:
                    
                    for d in exclude_chars:
                        if d in word[h]:
                            check = False
                         
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] > countw[f]:
                                    check = False
                        for g in countw:
                            if g not in countin:
                                check = False
                
            else:
                check = False
    else:
        check = False
    
#    print(check)
    return check

exec(input()) # DON'T remove this line

# 1663775, 2022-10-29 10:31:13, P--xx (20%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            if word[i] == pattern[i]:
                
                for d in exclude_chars:
                    if d in word[i]:
                        check = False
                    
                    else:   
                        countw = {} # {'M':1,'A':2}
                        for b in indq:
                            if word[b] in count:
                                count[word[b]] += 1
                            else:
                                count[word[b]] = 1
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] < countw[f]:
                                    check = False
                        for g in countw:
                            if g not in countin:
                                check = False
                
            else:
                check = False
    else:
        check = False
        
    return check

exec(input()) # DON'T remove this line
# 1663929, 2022-10-29 10:34:03, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    exclude_chars += ' '
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
            
    countw = {} # {'M':1,'A':2}
    
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
            a = int(a)
            if word[a] in countw:
                countw[word[a]] += 1
            else:
                countw[word[a]] = 1

    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            for h in indq:
                h = int(h)
                if word[i] == pattern[i]:
                    
                    for d in exclude_chars:
                        if d in word[h]:
                            check = False
                         
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] > countw[f]:
                                    check = False
                        for g in countw:
                            if g not in countin:
                                check = False
                
            else:
                check = False
    else:
        check = False

    return check

exec(input()) # DON'T remove this line

# 1664149, 2022-10-29 10:37:15, xPPPx (60%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    exclude_chars += ' '
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
            
    countw = {} # {'M':1,'A':2}
    
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
            a = int(a)
            if word[a] in countw:
                countw[word[a]] += 1
            else:
                countw[word[a]] = 1

    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            for h in indq:
                h = int(h)
                if word[i] == pattern[i]:
                    
                    for d in exclude_chars:
                        if d in word[h]:
                            check = False
                         
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] > countw[f]:
                                    check = False
                else:
                    check = False
    else:
        check = False
    

    return check

exec(input()) # DON'T remove this line

# 1664369, 2022-10-29 10:39:34, -PPPP (80%)

def match(word, pattern, include_chars, exclude_chars):
    indc = []
    indq = []
    check = True
    exclude_chars += ' '
    
    countin = {} # {'M':1,'A':2}
    for c in include_chars:
        if c in countin:
            countin[c] += 1
        else:
            countin[c] = 1
            
    countw = {} # {'M':1,'A':2}
    
    
    for a in range(len(pattern)):
        if pattern[a] != '?':
            indc += str(a)
        else:
            indq += str(a)
            a = int(a)
            if len(word) == len(pattern): 
                if word[a] in countw:
                    countw[word[a]] += 1
                else:
                    countw[word[a]] = 1

    
    if len(word) == len(pattern): 
        for i in indc:
            i = int(i)
            for h in indq:
                h = int(h)
                if word[i] == pattern[i]:
                    
                    for d in exclude_chars:
                        if d in word[h]:
                            check = False
                         
                        for f in countin:
                            if f not in countw:
                                check = False
                            else:
                                if countin[f] > countw[f]:
                                    check = False
                else:
                    check = False
    else:
        check = False
    

    return check

exec(input()) # DON'T remove this line


6530023021
# 1662431, 2022-10-29 09:57:57, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        if word[i] in exclude_chars:
            return False
    c = 0
    for i in range(len(include_chars)):
        a = word.find(include_chars[i],c)
        if a == -1:
            return False
        else:
            c = word.find(include_chars[i],c) + 1
    return True
exec(input()) # DON'T remove this line
# 1662746, 2022-10-29 10:07:46, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    q = ""
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        else:
            if word[i] in exclude_chars:
                return False
            q += word[i]
#     c = 0
#     for i in range(len(include_chars)):
#         a = q.find(include_chars[i],c)
#         if a == -1:
#             return False
#         else:
#             c = word.find(include_chars[i],c) + 1
    return True
exec(input()) # DON'T remove this line
# 1662946, 2022-10-29 10:13:13, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    q = ""
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        else:
            if word[i] in exclude_chars:
                return False
            q += word[i]
     for i in range(len(include_chars)):
         a = q.find(include_chars[i])
         if a == -1:
             return False
    return True
exec(input()) # DON'T remove this line
# 1662953, 2022-10-29 10:13:30, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    q = ""
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        else:
            if word[i] in exclude_chars:
                return False
            q += word[i]
    for i in range(len(include_chars)):
         a = q.find(include_chars[i])
         if a == -1:
             return False
    return True
exec(input()) # DON'T remove this line
# 1663186, 2022-10-29 10:19:15, PP-PP (80%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    q = ""
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        else:
            if word[i] in exclude_chars:
                return False
            q += word[i]
    c = 0
    s = ""
    for i in range(len(include_chars)):
         if include_chars[i] not in s:
             c = 0
         a = q.find(include_chars[i],c)
         if a == -1:
             return False
         else:
             s += include_chars[i]
             c = q.find(include_chars[i],c)+1
    return True
exec(input()) # DON'T remove this line
# 1663809, 2022-10-29 10:32:00, PP-PP (80%)

def match(word, pattern, include_chars, exclude_chars):
    if word == "":
      return False
    if len(word) != len(pattern):
        return False
    q = ""
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        else:
            if word[i] in exclude_chars:
                return False
            q += word[i]
    c = 0
    s = ""
    for i in range(len(include_chars)):
         if include_chars[i] not in s:
             c = 0
         a = q.find(include_chars[i],c)
         if a == -1:
             return False
         else:
             s += include_chars[i]
             c = q.find(include_chars[i],c)+1
    return True
exec(input()) # DON'T remove this line
# 1663817, 2022-10-29 10:32:09, PP-PP (80%)

def match(word, pattern, include_chars, exclude_chars):
    if word == "":
      return True
    if len(word) != len(pattern):
        return False
    q = ""
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
        else:
            if word[i] in exclude_chars:
                return False
            q += word[i]
    c = 0
    s = ""
    for i in range(len(include_chars)):
         if include_chars[i] not in s:
             c = 0
         a = q.find(include_chars[i],c)
         if a == -1:
             return False
         else:
             s += include_chars[i]
             c = q.find(include_chars[i],c)+1
    return True
exec(input()) # DON'T remove this line

6530050021
# 1662013, 2022-10-29 09:44:28, ----- (0%)

def match(w,p,inc,exc):
    r = True
    if len(w) != len(p):
        r = False
    k = 0
    a = ""
    while k != len(w):
        c = p.find("?",k)
        a += w[c]
        k = c+1
    for e in inc:
        if e not in a:
            r = False
    for e in a:
        if e in exc:
            r = False
    return r


print(match("MACMA", "M?C??", "AAA", ""))
    
# 1662039, 2022-10-29 09:45:18, TPTTT (20%)

def match(w,p,inc,exc):
    r = True
    if len(w) != len(p):
        r = False
    k = 0
    a = ""
    while k != len(w):
        c = p.find("?",k)
        a += w[c]
        k = c+1
    for e in inc:
        if e not in a:
            r = False
    for e in a:
        if e in exc:
            r = False
    return r


#print(match("MACMA", "M?C??", "MAA", "") )
    
    
exec(input())
# 1662046, 2022-10-29 09:45:25, TPTTT (20%)

def match(w,p,inc,exc):
    r = True
    if len(w) != len(p):
        r = False
    k = 0
    a = ""
    while k != len(w):
        c = p.find("?",k)
        a += w[c]
        k = c+1
    for e in inc:
        if e not in a:
            r = False
    for e in a:
        if e in exc:
            r = False
    return r


#print(match("MACMA", "M?C??", "MAA", "") )
    
    
exec(input())
# 1662323, 2022-10-29 09:54:21, ----- (0%)

def match(w,p,inc,exc):
    r = True
    if len(w) != len(p):
        r = False
    k = 0
    a = ""
    while k != len(w):
        c = p.find("?",k)
        if c == -1:
            break
        else:
            a += w[c]
            k = c+1
    for e in inc:
        if e not in a:
            r = False
    for e in a:
        if e in exc:
            r = False
    return r


print(match("MACMA", "M?C???", "", "") ) 
    
    
#exec(input())
# 1662350, 2022-10-29 09:55:18, -P-P- (40%)

def match(w,p,inc,exc):
    r = True
    if len(w) != len(p):
        r = False
    k = 0
    a = ""
    while k != len(w):
        c = p.find("?",k)
        if c == -1:
            break
        else:
            a += w[c]
            k = c+1
    for e in inc:
        if e not in a:
            r = False
    for e in a:
        if e in exc:
            r = False
    return r


#print() 
    
    
exec(input())
# 1662602, 2022-10-29 10:03:04, ---P- (20%)

def match(w,p,inc,exc):
    r = True
    if len(w) != len(p):
        r = False
    k = 0
    a = ""
    while k != len(w):
        c = p.find("?",k)
        if c == -1:
            break
        else:
            a += w[c]
            k = c+1
    if len(inc) == len(a):
        if inc != a:
            r = False
    else:
        for e in inc:
            if e not in a:
                r = False
        for e in a:
            if e in exc:
                r = False
    return r


#print(match("MACMA", "M?C??", "MAX", "") )
    
    
exec(input())
# 1663319, 2022-10-29 10:22:26, -PPPP (80%)

def match(w,p,inc,exc):
    r = True
    if len(w) != len(p):
        r = False
    k = 0
    a = ""
    while k != len(w):
        c = p.find("?",k)
        if c == -1:
            break
        else:
            a += w[c]
            k = c+1
    if len(inc) == len(a):
        b = []
        d = []
        for e in inc:
            d.append(e)
        for e in a:
            b.append(e)
        b.sort()
        d.sort()
        if b != d :
            r = False
    else:
        for e in inc:
            if e not in a:
                r = False
        for e in a:
            if e in exc:
                r = False
    return r


#print(match("MACMA", "M?C??", "AAA", ""))
    
    
exec(input())

6530045921
# 1662209, 2022-10-29 09:50:40, PPPxx (60%)

def check_pattern(s1,target) :
    if len(s1) != len(target) :
        return False
    s1 = s1.lower()
    target = target.lower()
    for i in range (len(s1)) :
        if target[i] != '?' and target[i] != s1[i] :
            return False
    return True

def check_include(w,p,x) :
    lw = []
    cw = []
    for i in range (len(w)) :
        lw.append(w[i])
    for i in range (len(p)) :
        if p[i] != "?" :
            cw.append(p[i])
    for i in range (len(x)) :
        cw.append(x[i])
    for i in range (len(cw)) :
        if cw[i] in lw :
            x =True
            lw.remove(cw[i])
        else :
            return False
    return True
        
def check_exclude(w,p,e) :
    lw = [] #word
    pw = [] #p
    ew = [] #e
    cw = [] #count
    for i in range (len(w)) :
        lw.append(w[i])
    for i in range (len(p)) :
        if p[i] != "?" :
            pw.append(p[i])
            cw.append(p[i])
    for i in range (len(e)) :
        ew.append(e[i])
        cw.append(c[i])
    for i in range (len(cw)) :
        if cw[i] in lw :
            x = True
            lw.remove(cw[i])
        else :
            return False
    for i in range (len(ew)) :
        if ew[i] in pw :
            y = True
            pw.remove(ew[i])
        else :
            return False
    return True
    
    


def match(word, pattern, include_chars, exclude_chars):
    x = 0
    if check_pattern(word, pattern) == True :
        x += 1
    if check_include(word,pattern,include_chars) == True :
        x += 1
    if check_exclude(word,pattern,exclude_chars) == True :
        x+= 1
    if x == 3 :
        return True
    else :
        return False
        
    
    




exec(input())
# 1662266, 2022-10-29 09:52:23, PPP-- (60%)

def check_pattern(s1,target) :
    if len(s1) != len(target) :
        return False
    s1 = s1.lower()
    target = target.lower()
    for i in range (len(s1)) :
        if target[i] != '?' and target[i] != s1[i] :
            return False
    return True

def check_include(w,p,x) :
    lw = []
    cw = []
    for i in range (len(w)) :
        lw.append(w[i])
    for i in range (len(p)) :
        if p[i] != "?" :
            cw.append(p[i])
    for i in range (len(x)) :
        cw.append(x[i])
    for i in range (len(cw)) :
        if cw[i] in lw :
            x =True
            lw.remove(cw[i])
        else :
            return False
    return True
        
def check_exclude(w,p,e) :
    lw = [] #word
    pw = [] #p
    ew = [] #e
    cw = [] #count
    for i in range (len(w)) :
        lw.append(w[i])
    for i in range (len(p)) :
        if p[i] != "?" :
            pw.append(p[i])
            cw.append(p[i])
    for i in range (len(e)) :
        ew.append(e[i])
        cw.append(e[i])
    for i in range (len(cw)) :
        if cw[i] in lw :
            x = True
            lw.remove(cw[i])
        else :
            return False
    for i in range (len(ew)) :
        if ew[i] in pw :
            y = True
            pw.remove(ew[i])
        else :
            return False
    return True
    
    


def match(word, pattern, include_chars, exclude_chars):
    x = 0
    if check_pattern(word, pattern) == True :
        x += 1
    if check_include(word,pattern,include_chars) == True :
        x += 1
    if check_exclude(word,pattern,exclude_chars) == True :
        x+= 1
    if x == 3 :
        return True
    else :
        return False
        
    
    




exec(input())
# 1663320, 2022-10-29 10:22:29, PPPP- (80%)

def check_pattern(s1,target) :
    if len(s1) != len(target) :
        return False
    s1 = s1.lower()
    target = target.lower()
    for i in range (len(s1)) :
        if target[i] != '?' and target[i] != s1[i] :
            return False
    return True

def check_include(w,p,x) :
    lw = []
    cw = []
    for i in range (len(w)) :
        lw.append(w[i])
    for i in range (len(p)) :
        if p[i] != "?" :
            cw.append(p[i])
    for i in range (len(x)) :
        cw.append(x[i])
    for i in range (len(cw)) :
        if cw[i] in lw :
            x =True
            lw.remove(cw[i])
        else :
            return False
    return True
        
def check_exclude(w,p,e) :
    lw = [] #word
    pw = [] #p
    ew = [] #e
    cw = [] #count
    new = []
    for i in range (len(w)) :
        lw.append(w[i])
    for i in range (len(p)) :
        if p[i] != "?" :
            pw.append(p[i])
            cw.append(p[i])
    for i in range (len(e)) :
        if e[i] in lw :
            ew.append(e[i])
    
    for i in range (len(cw)) :
        if cw[i] in lw :
            x =True
            lw.remove(cw[i])
        else :
            return False
    
    for i in range (len(ew)) :
        if ew[i] in pw :
            y = True
            pw.remove(ew[i])
        else :
            return False
    return True
    



def match(word, pattern, include_chars, exclude_chars):
    x = 0
    if check_pattern(word, pattern) == True :
        x += 1
    if check_include(word,pattern,include_chars) == True :
        x += 1
    if check_exclude(word,pattern,exclude_chars) == True :
        x+= 1
    if x == 3 :
        return True
    else :
        return False
        
    
    




exec(input())
# 1663866, 2022-10-29 10:33:05, PPPP- (80%)

def check_pattern(s1,target) :
    if len(s1) != len(target) :
        return False
    s1 = s1.lower()
    target = target.lower()
    for i in range (len(s1)) :
        if target[i] != '?' and target[i] != s1[i] :
            return False
    return True

def check_include(w,p,x) :
    lw = []
    cw = []
    for i in range (len(w)) :
        lw.append(w[i])
    for i in range (len(p)) :
        if p[i] != "?" :
            cw.append(p[i])
    for i in range (len(x)) :
        cw.append(x[i])
    for i in range (len(cw)) :
        if cw[i] in lw :
            x =True
            lw.remove(cw[i])
        else :
            return False
    return True
        
def check_exclude(w,p,e) :
    lw = [] #word
    pw = [] #p
    ew = [] #e
    cw = [] #count
    new = []
    for i in range (len(w)) :
        lw.append(w[i])
    for i in range (len(p)) :
        if p[i] != "?" :
            pw.append(p[i])
            cw.append(p[i])
    for i in range (len(e)) :
        if e[i] in lw :
            ew.append(e[i])
    
    for i in range (len(cw)) :
        if cw[i] in lw :
            x =True
            lw.remove(cw[i])
        else :
            return False
    for i in range (len(cw)) :
        ew.append(cw[i])
    for i in range (len(ew)) :
        if ew[i] in pw :
            y = True
            pw.remove(ew[i])
        else :
            return False
    return True
    



def match(word, pattern, include_chars, exclude_chars):
    x = 0
    if check_pattern(word, pattern) == True :
        x += 1
    if check_include(word,pattern,include_chars) == True :
        x += 1
    if check_exclude(word,pattern,exclude_chars) == True :
        x+= 1
    if x == 3 :
        return True
    else :
        return False
        
    
    




exec(input())

6530164921
# 1661586, 2022-10-29 09:28:40, ---P- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                if word[i] in exclude_chars:
                    return False
                else:
                    continue
            elif pattern[i] == word[i]:
                continue
        return True
    else:
        return False

exec(input())
# 1661674, 2022-10-29 09:31:25, -xxPx (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                if word[i] in exclude_chars:
                    return False
                elif word[i] in include_chars:
                    include_chars.remove(word[i])
            elif pattern[i] == word[i]:
                continue
        if include_chars == "":    
            return True
        else:
            return False
    else:
        return False

exec(input())
# 1661758, 2022-10-29 09:35:32, -PPPP (80%)

def match(word, pattern, include_chars, exclude_chars):
    inc_char = []
    for k in include_chars:
        inc_char.append(k)
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                if word[i] in exclude_chars:
                    return False
                elif word[i] in inc_char:
                    inc_char.remove(word[i])
            elif pattern[i] == word[i]:
                continue
        if inc_char == []:    
            return True
        else:
            return False
    else:
        return False

exec(input())
# 1663265, 2022-10-29 10:21:12, -PPPP (80%)

def match(word, pattern, include_chars, exclude_chars):
    inc_char = []
    for k in include_chars:
        inc_char.append(k)
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                if word[i] in exclude_chars:
                    return False
                elif word[i] in inc_char:
                    inc_char.remove(word[i])
            elif pattern[i] == word[i]:
                continue
        if inc_char == []:    
            return True
        else:
            return False
    else:
        return False

exec(input())

6530206621
# 1661822, 2022-10-29 09:38:14, x---- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    print("1")
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return false
    print("2")
    iq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            iq.append(i)
    for a in iq:
        if word[a] in exclude_chars:
            return False
    print("3")
    
    
    letter = []
    for a in iq:
        letter.append(word[a])
    letter.sort()
    ic = []
    for a in include_chars:
        ic.append(a)
    ic.sort()
    
    ic = ''.join(ic)
    letter = "".join(letter)
    print(ic)
    print(letter)
    if ic not in letter:
        return False
    print("4")
    return True
    
exec(input()) # DON'T remove this line

# 1661839, 2022-10-29 09:38:51, xPPPP (80%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
#     print("1")
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return false
#     print("2")
    iq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            iq.append(i)
    for a in iq:
        if word[a] in exclude_chars:
            return False
#     print("3")
    
    
    letter = []
    for a in iq:
        letter.append(word[a])
    letter.sort()
    ic = []
    for a in include_chars:
        ic.append(a)
    ic.sort()
    
    ic = ''.join(ic)
    letter = "".join(letter)
#     print(ic)
#     print(letter)
    if ic not in letter:
        return False
#     print("4")
    return True
    
exec(input()) # DON'T remove this line

# 1662176, 2022-10-29 09:49:50, xPPPP (80%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
#     print("1")
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return false
#     print("2")
    iq = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            iq.append(i)
    for a in iq:
        if word[a] in exclude_chars:
            return False
#     print("3")
    
    
    letter = []
    for a in iq:
        letter.append(word[a])
    letter.sort()
    ic = []
    for a in include_chars:
        ic.append(a)
    ic.sort()
    
    ic = ''.join(ic)
    letter = "".join(letter)
#     print(ic)
#     print(letter)
    dic = {}
    for a in ic:
        if a in dic:
            dic[a] += 1
        else:
            dic[a] = 1
#     print('dic=',dic)
    d2 = {}
    for a in letter:
        if a in d2:
            d2[a] += 1
        else:
            d2[a] = 1
#     print("d2=",d2)
    for a in dic:
        if a not in d2:
            return False
#         print("first")
        if dic[a] > d2[a]:
            return False
#         print("second")
#     print("4")
    return True
    
exec(input()) # DON'T remove this line

6530186721
# 1661845, 2022-10-29 09:39:03, xPPPx (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        sol = False
    check = ''
    for n,i in enumerate(pattern) :
        if i != '?' and i != word[n] :
            sol = False
        if i == '?' :
            check += word[n]
    check1 = check
    check2 = check
    for i in include_chars :
        position1 = check1.find(i)
        if position1 != -1 :
            check1 = check1[:position1] + check1[position1+1:]
        else :
            return False
    for i in exclude_chars :
        position2 = check2.find(i)
        if position2 != -1 :
            return False
    return True

exec(input())
# 1661928, 2022-10-29 09:41:32, -PPPP (80%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    check = ''
    for n,i in enumerate(pattern) :
        if i != '?' and i != word[n] :
            sol = False
        if i == '?' :
            check += word[n]
    check1 = check
    check2 = check
    for i in include_chars :
        position1 = check1.find(i)
        if position1 != -1 :
            check1 = check1[:position1] + check1[position1+1:]
        else :
            return False
    for i in exclude_chars :
        position2 = check2.find(i)
        if position2 != -1 :
            return False
    return True

exec(input())

6331119721
# 1663610, 2022-10-29 10:28:02, -PPPP (80%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if len(word) == len(pattern):
        c += 1
    
    d = []
    e = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] != '?':
                d.append([word[i],i])
                e.append([word[i],i])
        if d == e:
            c += 1
    dd = 0
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                if word[i] in exclude_chars:
                    dd += 1
        if dd == 0:
            c += 1
        else:
            pass
    ddd = 0
    ee = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                ee.append(word[i])
        for i in range(len(include_chars)):
            if include_chars[i] in ee:
                num = ee.index(include_chars[i])
                ee[num] = 0
                ddd += 1
                
            else:
                pass
        if ddd == len(include_chars):
            c += 1
            
    if c == 4:
        return True
    else:
        return False
            
                
            
            
            
    
            
        
        
                    
    
exec(input()) # DON'T remove this line

6531321221
# 1662027, 2022-10-29 09:45:04, -PPPP (80%)

def match(word, pattern, include_chars, exclude_chars):
    l_word = {}
    if len(word) != len(pattern):
        return False
    for s in word:
        if s in l_word:
            l_word[s] += 1
        else:
            l_word[s] = 1
    for s in pattern:
        if s in l_word:
            l_word[s] -= 1
        elif s != "?" and s not in l_word:
            return False
    for s in include_chars:
        if s in l_word:
            l_word[s] -= 1
        else:
            return False
    for i in l_word.values():
        if i < 0:
            return False
    for s in exclude_chars:
        for i in range(len(word)):
            if pattern[i] == "?":
                if s == word[i]:
                    return False
    return True


exec(input())

Max Score = 60


6532100021
# 1661580, 2022-10-29 09:28:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input()) # DON'T remove this line
# 1662060, 2022-10-29 09:46:00, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input()) # DON'T remove this line
# 1662063, 2022-10-29 09:46:06, P---- (20%)

def check2str(x,y):
    if len(x)!=len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower()==y[i].lower() or y[i]=="?"):
            return False
    return True            

def match(word, pattern, include_chars, exclude_chars):
    if check2str(word,pattern):
        return True
    return False     
    
exec(input()) # DON'T remove this line
# 1662242, 2022-10-29 09:51:37, x--Px (20%)

def check2str(x,y):
    if len(x)!=len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower()==y[i].lower() or y[i]=="?"):
            return False
    return True            

def match(word, pattern, include_chars, exclude_chars):
    for i in range(len(pattern)):
        if pattern[i] =="?":
            if word[i] in exclude_chars:
                return False    
    if check2str(word,pattern):
        return True
        
    return False     
    
exec(input()) # DON'T remove this line
# 1662298, 2022-10-29 09:53:28, x--Px (20%)

def check2str(x,y):
    if len(x)!=len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower()==y[i].lower() or y[i]=="?"):
            return False
    return True            

def match(word, pattern, include_chars, exclude_chars):
    for i in range(len(pattern)):
        if pattern[i] =="?":
            if word[i] in exclude_chars:
                return False    
    if check2str(word,pattern):
        return True
        
    return False     
    
exec(input()) # DON'T remove this line
# 1662332, 2022-10-29 09:54:40, P--P- (40%)

def check2str(x,y):
    if len(x)!=len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower()==y[i].lower() or y[i]=="?"):
            return False
    return True            

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] =="?":
            if word[i] in exclude_chars:
                return False    
    if check2str(word,pattern):
        return True
        
    return False     
    
exec(input()) # DON'T remove this line
# 1662402, 2022-10-29 09:57:09, PP-P- (60%)

def check2str(x, y):
    if len(x) != len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower() == y[i].lower() or y[i] == "?"):
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False
    if check2str(word, pattern):
        return True

    return False


exec(input())  # DON'T remove this line

# 1662405, 2022-10-29 09:57:11, PP-P- (60%)

def check2str(x, y):
    if len(x) != len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower() == y[i].lower() or y[i] == "?"):
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False
    if check2str(word, pattern):
        return True

    return False


exec(input())  # DON'T remove this line
# 1662600, 2022-10-29 10:03:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False
    
    return False


exec(input())  # DON'T remove this line

# 1662606, 2022-10-29 10:03:12, PP-P- (60%)

def check2str(x, y):
    if len(x) != len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower() == y[i].lower() or y[i] == "?"):
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False
    if check2str(word, pattern):
        return True

    return False


exec(input())  # DON'T remove this line
# 1662626, 2022-10-29 10:03:53, -P-P- (40%)

def check2str(x, y):
    if len(x) != len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower() == y[i].lower() or y[i] == "?"):
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False
    if check2str(word, pattern):
        return True

    return True


exec(input())  # DON'T remove this line
# 1662636, 2022-10-29 10:04:20, PP-P- (60%)

def check2str(x, y):
    if len(x) != len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower() == y[i].lower() or y[i] == "?"):
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False
    if check2str(word, pattern):
        return True

    return False


exec(input())  # DON'T remove this line
# 1662719, 2022-10-29 10:06:42, PP-P- (60%)

def check2str(x, y):
    if len(x) != len(y):
        return False
    for i in range(len(x)):
        if not(x[i].lower() == y[i].lower() or y[i] == "?"):
            return False
    return True


def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False
    if check2str(word, pattern):
        return True

    return False


exec(input())  # DON'T remove this line
# 1662984, 2022-10-29 10:14:13, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1663331, 2022-10-29 10:22:41, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return True

    return True


exec(input())  # DON'T remove this line
# 1663362, 2022-10-29 10:23:14, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1663385, 2022-10-29 10:23:44, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) != word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1663461, 2022-10-29 10:25:15, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) > word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1663490, 2022-10-29 10:25:45, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) < word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1663499, 2022-10-29 10:25:53, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) > word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1663729, 2022-10-29 10:30:30, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) >= word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line

# 1663745, 2022-10-29 10:30:44, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) > word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1663920, 2022-10-29 10:33:50, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in range(len(pattern)):
        if pattern[i]=="?":
            if include_chars.count(pattern[i])>word.count(pattern[i]):
                return False

    return True


exec(input())  # DON'T remove this line
# 1663926, 2022-10-29 10:33:58, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) > word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1664003, 2022-10-29 10:35:13, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in range(len(pattern)):
        if pattern[i]=="?":
            if include_chars.count(word[i])>word.count(word[i]):
                return False

    return True


exec(input())  # DON'T remove this line

# 1664057, 2022-10-29 10:35:54, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) > word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1664226, 2022-10-29 10:38:11, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) >= word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line
# 1664235, 2022-10-29 10:38:18, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if pattern[i] != word[i]:
                return False
    for i in range(len(pattern)):
        if pattern[i] == "?":
            if word[i] in exclude_chars:
                return False
    for i in include_chars:
        if include_chars.count(i) > word.count(i):
            return False

    return True


exec(input())  # DON'T remove this line

6530132821
# 1662493, 2022-10-29 09:59:32, ----- (0%)

print (True)
# 1662503, 2022-10-29 09:59:53, ----- (0%)

print (True)
# 1662506, 2022-10-29 10:00:02, ----- (0%)

print (False)
# 1662536, 2022-10-29 10:00:57, compilation error (0%)

def ret(x):
  if x == "5"
    return True

x = "5"
# 1662564, 2022-10-29 10:02:03, ----- (0%)

def ret(x):
  if x == "5":
    return True

ret("5")

# 1662701, 2022-10-29 10:06:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    ans = False
    if len(word) == len(pattern):
        ans = True
    return ans
exec(input()) # DON'T remove this line

# 1662769, 2022-10-29 10:08:23, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    ans = False
    if len(word) == len(pattern):
        ans = True
    return ans
exec(input()) # DON'T remove this line

# 1662921, 2022-10-29 10:12:43, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    return True
exec(input()) # DON'T remove this line


# 1663241, 2022-10-29 10:20:21, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    return True
exec(input()) # DON'T remove this line


# 1663389, 2022-10-29 10:23:48, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] != "?" in exclude_chars:
            return False
    for i in range(len(word)):
        if pattern[i] != "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    return True
exec(input()) # DON'T remove this line



# 1663450, 2022-10-29 10:24:57, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] != "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    return True
exec(input()) # DON'T remove this line



# 1663536, 2022-10-29 10:26:41, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == "?" :
            new_word += word[i]
    print(new_word)
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    return True
exec(input()) # DON'T remove this line



# 1663562, 2022-10-29 10:27:05, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    return True
exec(input()) # DON'T remove this line



# 1663730, 2022-10-29 10:30:31, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    if new_word != include_chars:
        return False
    return True
exec(input()) # DON'T remove this line



# 1663860, 2022-10-29 10:32:58, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    for i in range(len(include_chars)):
        if include_chars[i] not in new_word:
            return False
        return True
exec(input()) # DON'T remove this line



# 1663879, 2022-10-29 10:33:15, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    return True
exec(input()) # DON'T remove this line
# 1663956, 2022-10-29 10:34:23, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    for i in range(len(include_chars)):
        if include_chars[i] not in new_word:
            return False
    return True
exec(input()) # DON'T remove this line



# 1664012, 2022-10-29 10:35:21, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    for i in range(len(include_chars)):
        if include_chars[i] not in new_word:
            return False
    for i in range(len(new_word)):
        if new_word[i] not in include_chars:
            return False
    return True
exec(input()) # DON'T remove this line



# 1664034, 2022-10-29 10:35:39, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    new_word = ""
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == "?" :
            new_word += word[i]
    for i in range(len(new_word)):
        if new_word[i] in exclude_chars:
            return False
    for i in range(len(include_chars)):
        if include_chars[i] not in new_word:
            return False
    return True
exec(input()) # DON'T remove this line




6530065421
# 1662556, 2022-10-29 10:01:41, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
    
 
exec(input()) # DON'T remove this line

# 1663123, 2022-10-29 10:17:39, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])       
    for i in a :
        if i  in exclude_chars :         
            return False
        
        


        
        
# def aa(pattern,word) :
#     for i in range(len(pattern)) :
#         if pattern[i] == "?" :
#             a.append(word[i])
#     return a
# 
# def word_notin_in_exclude_chars(a,exclude_chars) :
#     for i in a :
#         if a  in exclude_chars :         
#             return False
#     return True
#         
        
            
        
    
 
exec(input()) # DON'T remove this line

# 1663293, 2022-10-29 10:21:48, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = []
    print(exclude_chars) 
    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
        print(a)
    for i in a :
        if i  in exclude_chars :         
            return False
    return True
    
        


        
        
exec(input()) # DON'T remove this line

# 1663355, 2022-10-29 10:23:06, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    a = []

    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
        
    for i in a :
        if i  in exclude_chars :         
            return False
    return True
    
        


        
        
exec(input()) # DON'T remove this line

# 1663530, 2022-10-29 10:26:34, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = []

    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not word :
            return False
    return True

    
        
# 1663549, 2022-10-29 10:26:50, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = []

    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not in word :
            return False
    return True

    
        
# 1663679, 2022-10-29 10:29:26, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    a = []

    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not in word :
            return False
    return True

    
        


        
# print(match("MACMA", "M?C??", "MAX", ""))    
exec(input()) # DON'T remove this line

# 1663761, 2022-10-29 10:30:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = []

    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not in word :
            return False
    for i in range(len(include_chars)) :
        if word[i] == include_chars[i] :
            return False
        
        
    return True

    
# 1664176, 2022-10-29 10:37:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = []

    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not in word :
            return False
    for i in range(len(include_chars)) :
        if word[i] == include_chars[i] :
            return False
        
        
    return True
# 1664289, 2022-10-29 10:38:50, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = []
    k = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
            k.append(word.find(word[i]))
            
            
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not in word :
            return False
    for i in range(len(include_chars)) :
        for i in range(len(k)) :
            if  include_chars[i] == word[k]  :
                return False
        
        
    return True

# 1664377, 2022-10-29 10:39:39, PxxPx (40%)

def match(word, pattern, include_chars, exclude_chars):
    a = []
    k = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
            k.append(word.find(word[i]))
            
            
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not in word :
            return False
    for i in range(len(include_chars)) :
        for i in range(len(k)) :
            if  include_chars[i] == word[k]  :
                return False
        
        
    return True
exec(input())
# 1664406, 2022-10-29 10:39:53, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    a = []
    k = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
            k.append(word.find(word[i]))
            
            
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not in word :
            return False
    for i in range(len(include_chars)) :
        for j in range(len(k)) :
            if  include_chars[i] == word[k[j]]  :
                return False
        
        
    return True

    
        


        
# print(match("MACMA", "M?C??", "MAX", ""))    
exec(input()) # DON'T remove this line

# 1664633, 2022-10-29 10:41:49, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    a = []

    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)) :
        if pattern[i] != "?" and pattern[i] != word[i] :
            return False
        if pattern[i] == "?" :
            a.append(word[i])
        
    for i in a :
        if i  in exclude_chars :         
            return False
        
        
    for i in include_chars :
        if i not in word :
            return False
    return True

    
        


        
# print(match("MACMA", "M?C??", "MAX", ""))    
exec(input()) # DON'T remove this line

6230089221
# 1662309, 2022-10-29 09:53:56, P---- (20%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    for e in exclude_chars:
        if e not in check:
            w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False
exec(input()) # DON'T remove this line
# 1662569, 2022-10-29 10:02:09, PP-P- (60%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    for e in include_chars:
        if e not in check:
            w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line
# 1662753, 2022-10-29 10:07:52, ----- (0%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    for e in check:
        if e not in include_chars:
            w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line
# 1662763, 2022-10-29 10:08:15, PP-P- (60%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    for e in include_chars:
        if e not in check:
            w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line
# 1662979, 2022-10-29 10:14:08, ----- (0%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    inc=[]
    for e in include_chars:
        inc.append(e)
    inc.sort()
    check.sort()
    if inc!=check:
        w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line
# 1662989, 2022-10-29 10:14:24, ----- (0%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    inc=[]
    for e in include_chars:
        inc.append(e)
    inc.sort()
    check.sort()
    if inc!=check:
        w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False
(exec(input())) # DON'T remove this line
# 1663062, 2022-10-29 10:15:57, PP-P- (60%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    for e in include_chars:
        if e not in check:
            w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line
# 1663124, 2022-10-29 10:17:41, ----- (0%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    inc=[]
    for e in include_chars:
        inc.append(e)
    inc.sort()
    check.sort()
    if inc!=check:
        w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line
# 1663152, 2022-10-29 10:18:23, PP-P- (60%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    for e in include_chars:
        if e not in check:
            w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line
# 1664304, 2022-10-29 10:38:57, P--P- (40%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    for i in range(len(include_chars)):
        if e not in check:
            w=False
        else:
            check.pop(i)
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line
# 1664330, 2022-10-29 10:39:10, PP-P- (60%)

def match2(word,pattern):
    z=True
    q=[]
    ei=[]
    for i in range(len(pattern)):
        if pattern[i]!="?":
            if pattern[i]!=word[i]:
                z=False
        else:
            ei.append(i)
            q.append(word[i])
        
    return z,q,ei
def match3(word,pattern,exclude_chars):
    z,q,ei=match2(word,pattern)
    t=True
    for e in q:
        if e in exclude_chars:
            t=False
    return t
def match4(word, pattern, include_chars, exclude_chars):
    z,q,ei=match2(word,pattern)
    check=[]
    for e in ei:
        check.append(word[e])
    w=True
    for e in include_chars:
        if e not in check:
            w=False
    return w
    
        
                
    
def match(word, pattern, include_chars, exclude_chars):
    sum=0
    if len(word)==len(pattern):
        sum+=1
    if sum==1:
        z,q,ei=match2(word,pattern)
        if z==True:
            sum+=1
    if sum==2:
        t=match3(word,pattern,exclude_chars)
        if t==True:
            sum+=1
    if sum==3:
        w=match4(word, pattern, include_chars, exclude_chars)
        if w==True:
            sum+=1
    if sum==4:
        return True
    else:
        return False

(exec(input())) # DON'T remove this line

6230098921
# 1662003, 2022-10-29 09:44:07, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != '?' :
                return False
        else :
            if pattern[i] == "?" :
                if pattern[i] in exclude :
                    return False
                elif pattern[i] not in include :
                    return False
    return True 
exec(input())
# 1662129, 2022-10-29 09:48:21, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != '?' :
                return False
        if pattern[i] == "?" :
            if word[i] in exclude :
                return False
            elif word[i] not in include :
                return False
    return True 
exec(input())
# 1662151, 2022-10-29 09:49:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):

    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != '?' :
                return False
        if pattern[i] == "?" :
            if word[i] in exclude :
                return False
            elif word[i] not in include :
                return False
    return True 
exec(input())
# 1662257, 2022-10-29 09:52:01, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and word[i] != '?' :
            return False
        elif pattern[i] == "?" :
            if word[i] in exclude :
                return False
            elif word[i] not in include :
                return False
            elif word[i] in include :
                include.remove(word[i])
    return True 
exec(input())
# 1662339, 2022-10-29 09:54:46, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):

    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and word[i] == '?' :
            return False
        elif pattern[i] == "?" :
            if word[i] in exclude :
                return False
            elif word[i] not in include :
                return False
            elif word[i] in include :
                include.remove(word[i])
    return True 
exec(input())
# 1662376, 2022-10-29 09:56:16, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):

    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return False
        elif pattern[i] == "?" :
            if word[i] in exclude :
                return False
            elif word[i] not in include :
                return False
            elif word[i] in include :
                include.remove(word[i])
    return True 
exec(input())
    
# 1662483, 2022-10-29 09:59:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):

    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != '?' :
                return False
        if pattern[i] == "?" :
            if word[i] in exclude :
                return False
            elif word[i] not in include :
                return False
            elif word[i] in include :
                include.remove(word[i])
    return True 
exec(input())
    
# 1662580, 2022-10-29 10:02:27, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if p[i] != "?" and x[i] != p[i] :
            return False
        elif pattern[i] == "?" :
            if word[i] in exclude :
                return False
            elif word[i] not in include :
                return False
            elif word[i] in include :
                include.remove(word[i])
    return True 
exec(input())
# 1663150, 2022-10-29 10:18:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):

    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    n = 0
    for e in pattern :
        if e == '?' :
            n += 1
    if n != len(include) :
        return False
    for i in range(len(word)) :
        if pattern[i] == '?' :
            if word[i] not in include :
                return False
            if word[i] in exclude :
                return False
        elif word[i] != pattern[i] :
            return False
    return True 
exec(input())
# 1663765, 2022-10-29 10:31:01, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):

    include = []
    exclude = []
    for e in exclude_chars :
        exclude.append(e)
    for e in include_chars :
        include.append(e)
    if len(word) != len(pattern) :
        return False
    n = 0
    for e in pattern :
        if e == '?' :
            n += 1
    if n < len(include) :
        return False
    for i in range(len(word)) :
        if pattern[i] == '?' :
            if word[i] in exclude :
                return False
        elif word[i] != pattern[i] :
            return False
        else :
            for e in include :
                if e not in word :
                    return False
    return True 
exec(input())

6530090021
# 1662475, 2022-10-29 09:59:00, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
    def cat(x,y):
        if len(x)!=len(y):
            return False
        else:
            for i in range(len(x)):
                if x[i] == y[i] or y[i] == '?':
                    pass
                else:
                    return False
    if cat(word,pattern) != False :
        return True
    else:
        return False
     

# 1663058, 2022-10-29 10:15:51, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
    def cat(x,y):
        if len(x)!=len(y):
            return False
        else:
            for i in range(len(x)):
                if x[i] == y[i] or y[i] == '?':
                    pass
                else:
                    return False
    def dog(x,y):
        for i in y:
            if i in x or i == '':
                pass
            else:
                return False
    if cat(word,pattern) != False and dog(word,include_chars) != False:
        return True
    else:
        return False
    


# 1663218, 2022-10-29 10:19:49, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
    def cat(x,y):
        if len(x)!=len(y):
            return False
        else:
            for i in range(len(x)):
                if x[i] == y[i] or y[i] == '?':
                    pass
                else:
                    return False
    def dog(x,y):
        for i in y:
            if i in x or i == '':
                pass
            else:
                return False
    def fish(x,y):
        for i in y:
            if i == 'x':
                return True
            elif i in x :
                return False
            
    if cat(word,pattern) != False and dog(word,include_chars) != False and fish(word,exclude_chars) != False:
        return True
    else:
        return False
    
print(match("MACMA", "M?C??", "MAA", ""))

# 1663288, 2022-10-29 10:21:44, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
    def cat(x,y):
        if len(x)!=len(y):
            return False
        else:
            for i in range(len(x)):
                if x[i] == y[i] or y[i] == '?':
                    pass
                else:
                    return False
    def dog(x,y):
        for i in y:
            if i in x or i == '':
                pass
            else:
                return False
    def fish(x,y):
        for i in y:
            if i == x:
                return True
            elif i in x :
                return False
            
    if cat(word,pattern) != False and dog(word,include_chars) != False and fish(word,exclude_chars) != False:
        return True
    else:
        return False
    
match("MACMA", "MACMA", "", "MACMA")

# 1663369, 2022-10-29 10:23:24, PP-P- (60%)

def  match(word, pattern, include_chars, exclude_chars):
    def cat(x,y):
        if len(x)!=len(y):
            return False
        else:
            for i in range(len(x)):
                if x[i] == y[i] or y[i] == '?':
                    pass
                else:
                    return False
    def dog(x,y):
        for i in y:
            if i in x or i == '':
                pass
            else:
                return False
    def fish(x,y):
        for i in y:
            if i == x:
                return True
            elif i in x :
                return False
            
    if cat(word,pattern) != False and dog(word,include_chars) != False and fish(word,exclude_chars) != False:
        return True
    else:
        return False
    
exec(input()) 

# 1663505, 2022-10-29 10:26:03, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
  print(True)
  
exec(input()) 
# 1663542, 2022-10-29 10:26:44, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
  return True
  
exec(input())
# 1663552, 2022-10-29 10:26:53, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
  return False
  
exec(input())
# 1663557, 2022-10-29 10:27:00, PP-P- (60%)

def  match(word, pattern, include_chars, exclude_chars):
    def cat(x,y):
        if len(x)!=len(y):
            return False
        else:
            for i in range(len(x)):
                if x[i] == y[i] or y[i] == '?':
                    pass
                else:
                    return False
    def dog(x,y):
        for i in y:
            if i in x or i == '':
                pass
            else:
                return False
    def fish(x,y):
        for i in y:
            if i == x:
                return True
            elif i in x :
                return False
            
    if cat(word,pattern) != False and dog(word,include_chars) != False and fish(word,exclude_chars) != False:
        return True
    else:
        return False
    
exec(input()) 


6532106921
# 1662641, 2022-10-29 10:04:24, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)): 
        print(False)
        exit(0)
        
    n=len(word)
    for i in range(n):
        if(word[i]!=pattern[i] and pattern[i]!='?'):
            print(False)
            exit(0)
    
    for i in range(n):
        if(pattern[i]=='?'):
            for ex in exclude_chars:
                if(word[i]==ex):
                    print(False)
                    exit(0)              
    for i in range(n):
        if(pattern[i]=='?'):
            for i in range(len(include_chars)):
                if(word[i]==include_chars[i]):
                    include_chars=include_chars[:i]+'*'+include_chars[i+1:]
                    break
                print(False)
                exit(0)
    print(True)
exec(input()) # DON'T remove this line
# 1662873, 2022-10-29 10:11:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)): 
        print(False)
        exit(0)

    n=len(word)
    for i in range(n):
        if(word[i]!=pattern[i] and pattern[i]!='?'):
            print(False)
            exit(0)
    
    for i in range(n):
        if(pattern[i]=='?'):
            for ex in exclude_chars:
                if(word[i]==ex):
                    print(False)
                    exit(0)     
    for i in range(n):
        if(pattern[i]=='?'):
            ch=0
            for j in range(len(include_chars)):
                #print(word[i],include_chars[j])
                if(word[i]==include_chars[j]):
                    #print(word[i],include_chars[j])
                    include_chars=include_chars[:j]+'*'+include_chars[j+1:]
                    ch=1
                    break
            if(not ch):
                print(False)
                exit(0)                  
    print(True)
exec(input()) # DON'T remove this line
# 1662971, 2022-10-29 10:14:00, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)): 
        return False

    n=len(word)
    for i in range(n):
        if(word[i]!=pattern[i] and pattern[i]!='?'):
            return False
    print(2)
    for i in range(n):
        if(pattern[i]=='?'):
            for ex in exclude_chars:
                if(word[i]==ex):
                    return False  
    print(3)
    for i in range(n):
        if(pattern[i]=='?'):
            ch=0
            for j in range(len(include_chars)):
                #print(word[i],include_chars[j])
                if(word[i]==include_chars[j]):
                    #print(word[i],include_chars[j])
                    include_chars=include_chars[:j]+'*'+include_chars[j+1:]
                    ch=1
                    break
            if(not ch):
                return False                 
    return True
exec(input()) # DON'T remove this line
# 1662986, 2022-10-29 10:14:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input()) # DON'T remove this line
# 1662992, 2022-10-29 10:14:27, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input()) # DON'T remove this line
# 1663000, 2022-10-29 10:14:36, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    print(True)
exec(input()) # DON'T remove this line
# 1663009, 2022-10-29 10:14:48, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)): 
        return False

    n=len(word)
    for i in range(n):
        if(word[i]!=pattern[i] and pattern[i]!='?'):
            return False
    print(2)
    for i in range(n):
        if(pattern[i]=='?'):
            for ex in exclude_chars:
                if(word[i]==ex):
                    return False  
    print(3)
    for i in range(n):
        if(pattern[i]=='?'):
            ch=0
            for j in range(len(include_chars)):
                #print(word[i],include_chars[j])
                if(word[i]==include_chars[j]):
                    #print(word[i],include_chars[j])
                    include_chars=include_chars[:j]+'*'+include_chars[j+1:]
                    ch=1
                    break
            if(not ch):
                return False                 
    return True
exec(input()) # DON'T remove this line
# 1664088, 2022-10-29 10:36:18, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)): 
        return False

    n=len(word)
    for i in range(n):
        if(word[i]!=pattern[i] and pattern[i]!='?'):
            return False
    for i in range(n):
        if(pattern[i]=='?'):
            for ex in exclude_chars:
                if(word[i]==ex):
                    return False  
    #print(2222)
    mark=include_chars
    for i in range(n):
        if(pattern[i]=='?'):
            ch=0
            for j in range(len(include_chars)):
                #print(word[i],include_chars[j])
                if(word[i]==include_chars[j]):
                    for k in range(len(mark)):
                        if(mark[k]=='*'): continue
                        mark=mark[:k]+'*'+mark[k+1:]
                    ch=1
                    break
    for i in range(len(mark)):
        if(mark[i]!='*'):
            return False
    return True
exec(input()) # DON'T remove this line
# 1664225, 2022-10-29 10:38:11, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if(len(word)!=len(pattern)): 
        return False

    n=len(word)
    for i in range(n):
        if(word[i]!=pattern[i] and pattern[i]!='?'):
            return False
    for i in range(n):
        if(pattern[i]=='?'):
            for ex in exclude_chars:
                if(word[i]==ex):
                    return False  
    mark=include_chars
    for i in range(n):
        if(pattern[i]=='?'):
            ch=0
            for j in range(len(include_chars)):
                if(word[i]==include_chars[j]):
                    for k in range(len(mark)):
                        if(mark[k]=='*'): continue
                        mark=mark[:k]+'*'+mark[k+1:]
                        break
                    ch=1
                    break
    for i in range(len(mark)):
        if(mark[i]!='*'):
            return False
    return True
exec(input()) # DON'T remove this line

6531017521
# 1663072, 2022-10-29 10:16:10, ----- (0%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        bullen = False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                bullen = False
    for i in range(len(include_chars)):
        for j in range(len(pattern)):
            if pattern[i] == "?":
                if word[j] in exclude_chars:
                    bullen = False
    return bullen

# 1663171, 2022-10-29 10:18:52, x--Px (20%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        bullen = False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                bullen = False
    for i in range(len(pattern)):
           if pattern[i] == "?":
               if word[i] in exclude_chars:
                   bullen = False

    
    return bullen
exec(input())
# 1663321, 2022-10-29 10:22:31, xxxPx (20%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        bullen = False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                bullen = False
    for i in range(len(pattern)):
           if pattern[i] == "?":
               if word[i] in exclude_chars:
                   bullen = False
    for i in range(len(include_chars)):
        for j in range(len(pattern)):
            if pattern[j] == "?":
                if include_chars[i] in word:
                    if include_chars[i] == word[j]:
                        word.pop(j)
                else :
                    bullen = False
                
                
    
    return bullen
exec(input())

# 1663764, 2022-10-29 10:30:59, ----- (0%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        bullen = False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                bullen = False
    for i in range(len(pattern)):
           if pattern[i] == "?":
               if word[i] in exclude_chars:
                   bullen = False
    for i in range(len(include_chars)):
        for j in range(len(pattern)):
            if pattern[j] == "?":
                if include_chars[i] in word:
                    if include_chars[i] == word[j]:
                        word.replace(word[j]," ",1)
                        include_chars.replace(include_chars[i]," ",1)
                else :
                    bullen = False
                
                
    
    return bullen


# 1663849, 2022-10-29 10:32:48, xP-Px (40%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        bullen = False
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                bullen = False
    for i in range(len(pattern)):
           if pattern[i] == "?":
               if word[i] in exclude_chars:
                   bullen = False
    for i in range(len(include_chars)):
        for j in range(len(pattern)):
            if pattern[j] == "?":
                if include_chars[i] in word:
                    if include_chars[i] == word[j]:
                        word.replace(word[j]," ",1)
                        include_chars.replace(include_chars[i]," ",1)
                else :
                    bullen = False
                
                
    
    return bullen
exec(input())

# 1663945, 2022-10-29 10:34:10, PP-P- (60%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        return False
         
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                bullen = False
    for i in range(len(pattern)):
           if pattern[i] == "?":
               if word[i] in exclude_chars:
                   bullen = False
    for i in range(len(include_chars)):
        for j in range(len(pattern)):
            if pattern[j] == "?":
                if include_chars[i] in word:
                    if include_chars[i] == word[j]:
                        word.replace(word[j]," ",1)
                        include_chars.replace(include_chars[i]," ",1)
                else :
                    bullen = False
                
                
    
    return bullen
exec(input())

# 1664256, 2022-10-29 10:38:31, P--P- (40%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        return False
         
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                return False
    for i in range(len(pattern)):
           if pattern[i] == "?":
               if word[i] in exclude_chars:
                   return False
    for i in range(len(include_chars)):
        for j in range(len(pattern)):
            if pattern[j] == "?":
                if include_chars[i] == word[j]:
                    word.replace(word[j]," ",1)
                    include_chars.replace(include_chars[i]," ",1)
                else :
                    return False
                
                
    
    return bullen
exec(input())

# 1664277, 2022-10-29 10:38:44, P--P- (40%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        return False
         
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                return False
    for i in range(len(pattern)):
           if pattern[i] == "?":
               if word[i] in exclude_chars:
                   return False
    for i in range(len(include_chars)):
        for j in range(len(pattern)):
            if pattern[j] == "?":
                if include_chars[i] == word[j]:
                    if include_chars[i] == word[j]:
                        word.replace(word[j]," ",1)
                        include_chars.replace(include_chars[i]," ",1)
                else :
                    return False
                
                
    
    return bullen
exec(input())

# 1664307, 2022-10-29 10:38:58, PP-P- (60%)

def match(word, pattern , include_chars, exclude_chars):
    bullen = True 
    if not len(word) == len(pattern):
        return False
         
    for i in range(len(pattern)):
        if pattern[i] != "?":
            if not word[i] == pattern[i]:
                bullen = False
    for i in range(len(pattern)):
           if pattern[i] == "?":
               if word[i] in exclude_chars:
                   bullen = False
    for i in range(len(include_chars)):
        for j in range(len(pattern)):
            if pattern[j] == "?":
                if include_chars[i] in word:
                    if include_chars[i] == word[j]:
                        word.replace(word[j]," ",1)
                        include_chars.replace(include_chars[i]," ",1)
                else :
                    bullen = False
                
                
    
    return bullen
exec(input())


6531020321
# 1662466, 2022-10-29 09:58:46, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != '?' and word[i] != pattern(i):
            return False
    for i in range(len(word)):
        if word[i] == '?':
            if word[i] in exclude_chars:
                return False
    return True
exec(input()) # DON'T remove this line
# 1662784, 2022-10-29 10:08:46, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != '?' and word[i] != pattern[i]:
            return False
    for i in range(len(word)):
        if word[i] == '?':
            if word[i] in exclude_chars:
                return False
    x = ''
    for c in include_chars:
        if c not in word:
            return False
    j = pattern.find('?')
    for c in include_chars:        
        if word.find(c,j) != pattern.find('?',j):
            return False
        else:
            j = patten.find('?',j+1)
    return True
exec(input()) # DON'T remove this line
# 1663594, 2022-10-29 10:27:39, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] != '?':
                return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    return True
exec(input()) # DON'T remove this line
# 1663819, 2022-10-29 10:32:10, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] != '?':
                return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    j = pattern.find('?')
    for c in include_chars:
        if c not in word:
            return False
        j = pattern.find('?',j+1)
    return True
exec(input()) # DON'T remove this line


# 1663898, 2022-10-29 10:33:29, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] != '?':
                return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    j = pattern.find('?')
    for c in include_chars:
        if c not in word:
            return False
        if c != word[j]:
            return False
        j = pattern.find('?',j+1)
    return True
exec(input()) # DON'T remove this line
# 1663908, 2022-10-29 10:33:41, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] != '?':
                return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    j = pattern.find('?')
    for c in include_chars:
        if c not in word:
            return False
        j = pattern.find('?',j+1)
    return True
exec(input()) # DON'T remove this line
# 1664047, 2022-10-29 10:35:50, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] != '?':
                return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    j = pattern.find('?')
    for c in include_chars:
        if c not in word:
            return False
        if word.find(c,j) != j:
            return False
        j = pattern.find('?',j+1)
    return True
exec(input()) # DON'T remove this line
# 1664082, 2022-10-29 10:36:11, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] != '?':
                return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    j = pattern.find('?')
    for c in include_chars:
        if c not in word:
            return False
        j = pattern.find('?',j+1)
    return True
exec(input()) # DON'T remove this line

6530008721
# 1661593, 2022-10-29 09:28:49, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    result = True:
    if len(word) != len(pattern):
        result = False
        return result

exec(input())

# 1661612, 2022-10-29 09:29:22, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    result = True
    if len(word) != len(pattern):
        result = False
        return result

exec(input())
# 1661934, 2022-10-29 09:41:37, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    result = True
    if len(word) != len(pattern):
        result = False
        return result
    
    else:
        for i in range(len(word)):
            if pattern[i] != word[i] and pattern[i] != '?':
                result = False
                return result
            break
    
    if result == True:
        checker = []
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checker.append(word[i])
        for c in checker:
            if c in exclude_chars:
                result = False
                return result
            break
    
    if result == True:
        
                

exec(input())

# 1661938, 2022-10-29 09:41:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    result = True
    if len(word) != len(pattern):
        result = False
        return result
    
    else:
        for i in range(len(word)):
            if pattern[i] != word[i] and pattern[i] != '?':
                result = False
                return result
            break
    
    if result == True:
        checker = []
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checker.append(word[i])
        for c in checker:
            if c in exclude_chars:
                result = False
                return result
            break
        
                

exec(input())
# 1662024, 2022-10-29 09:45:00, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    result = True
    if len(word) != len(pattern):
        result = False
        return result
    
    else:
        for i in range(len(word)):
            if pattern[i] != word[i] and pattern[i] != '?':
                result = False
                return result
            break
    
    if result == True:
        checker = []
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checker.append(word[i])
        for c in checker:
            if c in exclude_chars:
                result = False
                return result
            break
    
    if result == True:
        checker = []
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checker.append(word[i])
        for c in include_chars:
            if c not in checker:
                result = False
                return result
            break
    
    if result == True:
        return result
        
        
                

exec(input())

# 1662174, 2022-10-29 09:49:49, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    result = True
    if len(word) != len(pattern):
        result = False
        
    else:
        for i in range(len(word)):
            if pattern[i] != word[i] and pattern[i] != '?':
                result = False
    
    if result == True:
        checker = []
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checker.append(word[i])
        for c in checker:
            if c in exclude_chars:
                result = False
    
    if result == True:
        checker = []
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checker.append(word[i])
        for c in include_chars:
            if c not in checker:
                result = False
        
    return result
        
        
                
n = input().strip()
exec(n)

# 1662253, 2022-10-29 09:51:48, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    result = True
    if len(word) != len(pattern):
        result = False
        
    else:
        for i in range(len(word)):
            if pattern[i] != word[i] and pattern[i] != '?':
                result = False
    
    if result == True:
        checker = []
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checker.append(word[i])
        for c in checker:
            if c in exclude_chars:
                result = False
    
    if result == True:
        checker = []
        for i in range(len(pattern)):
            if pattern[i] == '?':
                checker.append(word[i])
        for c in include_chars:
            if c not in checker:
                result = False
        
    return result
        
        
                
exec(input())

6531810821
# 1662847, 2022-10-29 10:10:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern) :return False
    
    for i in range(len(word)):
        if pattern[i] != word[i] and pattern[i] != "?" : return False
        
    w1 = sorted(word.strip())
    ic = sorted(include_chars.strip())
    for i in ic :
        if i not in w1 :return False       
        
    for i in exclude_chars :
        if exclude_chars in word : return False
    
    return True 
print(match("MACMA", "M?C??", "AM", "") )     
exec(input())
# 1662857, 2022-10-29 10:10:42, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern) :return False
    
    for i in range(len(word)):
        if pattern[i] != word[i] and pattern[i] != "?" : return False
        
    w1 = sorted(word.strip())
    ic = sorted(include_chars.strip())
    for i in ic :
        if i not in w1 :return False       
        
    for i in exclude_chars :
        if exclude_chars in word : return False
    
    return True 
  
exec(input())
# 1663156, 2022-10-29 10:18:30, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern) : return False
    
    for i in range(len(word)):
        if pattern[i] != word[i] and pattern[i] != "?" :  return False
    
    
    w1 = sorted(word.strip())
    ic = sorted(include_chars.strip())
    for i in ic :
        if ic.count(i) != w1.count(i) : return False 
        if i not in w1 : return False       

    for i in exclude_chars :
        if i in word : return False
  
exec(input())
# 1663167, 2022-10-29 10:18:49, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern) : return False
    
    for i in range(len(word)):
        if pattern[i] != word[i] and pattern[i] != "?" :  return False
    
    
    w1 = sorted(word.strip())
    ic = sorted(include_chars.strip())
    for i in ic :
        if ic.count(i) != w1.count(i) : return False 
        if i not in w1 : return False       

    for i in exclude_chars :
        if i in word : return False
    
    return True
  
exec(input())
# 1664257, 2022-10-29 10:38:31, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern) : return False
    
    for i in range(len(word)):
        if pattern[i] != word[i] and pattern[i] != "?" :  return False
        elif pattern = word : return True 
    
    
    w1 = sorted(word.strip())
    ic = sorted(include_chars.strip())
    for i in ic :
        if ic.count(i) != w1.count(i) : return False 
        if i not in w1 : return False       

    for i in exclude_chars :
        if i in word : return False
    
    return True 

exec(input())
# 1664280, 2022-10-29 10:38:45, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern) : return False
    
    for i in range(len(word)):
        if pattern[i] != word[i] and pattern[i] != "?" :  return False
        elif pattern = word : return True 
    
    w1 = sorted(word.strip())
    ic = sorted(include_chars.strip())
    for i in ic :
        if ic.count(i) != w1.count(i) : return False 
        if i not in w1 : return False       

    for i in exclude_chars :
        if i in word : return False
    
    return True 

exec(input())
# 1664335, 2022-10-29 10:39:16, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern) : return False
    
    for i in range(len(word)):
        if pattern[i] != word[i] and pattern[i] != "?" :  return False
        elif pattern == word : return True 
    
    w1 = sorted(word.strip())
    ic = sorted(include_chars.strip())
    for i in ic :
        if ic.count(i) != w1.count(i) : return False 
        if i not in w1 : return False       

    for i in exclude_chars :
        if i in word : return False
    
    return True 

exec(input())

6430115021
# 1662390, 2022-10-29 09:56:40, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern) :
     return False
 for i in range (len(pattern)):
     if pattern[i] != "?" and pattern[i] != word[i] :
         return False
 
 
 
 
 
 
 return True












exec(input()) # DON'T remove this line
# 1662420, 2022-10-29 09:57:35, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern) :
     return False
 for i in range (len(pattern)):
     if pattern[i] != "?" and pattern[i] != word[i] :
         return False
 
 
 
 
 
 
 return True












exec(input()) # DON'T remove this line
# 1662655, 2022-10-29 10:04:51, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern) :
     return False
 for i in range (len(pattern)):
     if pattern[i] != "?" and pattern[i] != word[i] :
         return False
 for i in range (len(pattern)):
     if pattern[i] == '?' :
         if word[i] in  exclude_chars :
             return False
 for i in range (len(include_chars)) :
     
 
 
 
 
 return True


exec(input()) # DON'T remove this line
# 1662678, 2022-10-29 10:05:29, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern) :
     return False
 for i in range (len(pattern)):
     if pattern[i] != "?" and pattern[i] != word[i] :
         return False
  for i in range (len(pattern)):
     if pattern[i] == '?' :
         if word[i] in  exclude_chars :
             return False
 
 
 
 
 
 
 return True












exec(input()) # DON'T remove this line
# 1662689, 2022-10-29 10:05:47, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern) :
     return False
 for i in range (len(pattern)):
     if pattern[i] != "?" and pattern[i] != word[i] :
         return False
 for i in range (len(pattern)):
     if pattern[i] == '?' :
         if word[i] in  exclude_chars :
             return False
 
 
 
 
 
 
 return True












exec(input()) # DON'T remove this line
# 1663013, 2022-10-29 10:14:54, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
 x = ''
 if len(word) != len(pattern) :
     return False
 for i in range (len(pattern)):
     if pattern[i] != "?" and pattern[i] != word[i] :
         return False
 for i in range (len(pattern)):
     if pattern[i] == '?' :
         if word[i] in  exclude_chars :
             return False
 for i in range (len(pattern)):
     if pattern[i] == '?' :
         x += word[i]
 if len(include_chars) != 0 :
     for i in range (len(include_chars)):
             if include_chars[i] not in x :
                 return False
     
     
 
 
 
 
 return True












exec(input()) # DON'T remove this line

6430382221
# 1662575, 2022-10-29 10:02:21, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = []
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern [i] =='?':
            x.append(word[i])
 
    for i in include_chars:
        if i not in x:
            return False
        x.
    for i in exclude_chars:
        if i in x:
            return False
    return True
exec(input()) # DON'T remove this line
# 1662709, 2022-10-29 10:06:30, -P-P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    x = []
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern [i] =='?':
            x.append(word[i])
 
    for i in include_chars:
        if i not in x:
            return False
    for i in exclude_chars:
        if i in x:
            return False
    
    return True

exec(input()) # DON'T remove this line
# 1663132, 2022-10-29 10:17:50, -P-P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    x = []
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern [i] =='?':
            x.append(word[i])
    if len(include_chars) > len(x):
      return false
    for i in include_chars:
        if i not in x:
            return False
    for i in exclude_chars:
        if i in x:
            return False
    
    return True

exec(input()) # DON'T remove this line
# 1663414, 2022-10-29 10:24:14, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = []
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern [i] =='?':
            x.append(word[i])
    if len(include_chars) > len(x):
      return false
    for i in include_chars:
        if i not in x:
            return False
    for i in exclude_chars:
        if i in x:
            return False
    for i in range(len(pattern)):
      if pattern[i] != word[i] or pattern[i] != '?':
          return False
    return True

exec(input()) # DON'T remove this line
# 1663431, 2022-10-29 10:24:38, -P-P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    x = []
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern [i] =='?':
            x.append(word[i])
    if len(include_chars) > len(x):
      return false
    for i in include_chars:
        if i not in x:
            return False
    for i in exclude_chars:
        if i in x:
            return False

    return True

exec(input()) # DON'T remove this line
# 1663646, 2022-10-29 10:28:42, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    x = []
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern [i] =='?':
            x.append(word[i])
    if len(include_chars) > len(x):
      return false
    for i in include_chars:
        if i not in x:
            return False
    for i in exclude_chars:
        if i in x:
            return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] :
            if pattern[i] != '?':
                return False
    return True

exec(input()) # DON'T remove this line

6530068321
# 1662613, 2022-10-29 10:03:17, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=x[i].lower():
            return False
    return True
exec(input()) # DON'T remove this line
# 1662671, 2022-10-29 10:05:25, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
            return False
    return True
exec(input())
# 1663073, 2022-10-29 10:16:11, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
            return False
        if pattern[i]=="?" and (word[i] in exclude_chars):
            return False
        if  include_chars[i] not in word:
            return False
    return True
exec(input()) # DON'T remove this line
# 1663111, 2022-10-29 10:17:18, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
            return False
        if pattern[i]=="?" and (word[i] in exclude_chars):
            return False

    return True
exec(input()) # DON'T remove this line
# 1663230, 2022-10-29 10:20:05, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
            return False
        if pattern[i]=="?" and (word[i] in exclude_chars):
            return False
    for i in range(len(include_chars)):
        if  include_chars[i] not in word:
            return False

    return True
exec(input())
# 1663477, 2022-10-29 10:25:31, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    x=[]
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
            return False
        if pattern[i]=="?" and (word[i] in exclude_chars):
            return False
    for i in range(len(include_chars)):
        if  include_chars[i] not in word:
            return False
        else:
            x.append(i)
    y=sorted(x)
    for i in range(len(y)-3):
        if y[i]==y[i+1]:
            return False

    return True
exec(input())

6530042021
# 1661486, 2022-10-29 09:25:52, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    c = 0
    for i in range(len(include_chars)):
        if include_chars[i] == word[i]:
            c += 1
    if c == len(include_chars) :
        return True
    else :
        return False
        
    
exec(input()) # DON'T remove this line
# 1661496, 2022-10-29 09:26:05, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    c = 0
    for i in range(len(include_chars)):
        if include_chars[i] == word[i]:
            c += 1
    if c == len(include_chars) :
        return True
    else :
        return False
        
exec(input()) # DON'T remove this line
# 1661556, 2022-10-29 09:28:01, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    c = 0
    for i in range(len(include_chars)):
        if include_chars[i] == word[i]:
            c += 1
    if c == len(include_chars) :
        return True
    else :
        return False
        
    
exec(input()) # DON'T remove this line
# 1661689, 2022-10-29 09:32:23, ---P- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            c = 0
            for i in range(len(include_chars)):
                if include_chars[i] == word[i]:
                    c += 1
            if c == len(include_chars) :
                return True
            else :
                return False
            
    
exec(input()) # DON'T remove this line
# 1661896, 2022-10-29 09:40:17, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    c = []
    for i in range(len(word)):
        if pattern[i] == '?':
            c.append(word[i])
    for i in range(len(include_chars)):
        if include_chars[i] not in c:
            return False
    return True
            
            
    
exec(input()) # DON'T remove this line

6530046521
# 1662649, 2022-10-29 10:04:44, ----- (0%)

def include(word, pattern, include_chars):
    s1 = ''
    s2 = ''
    for i in range(len(word)):
        if pattern[i] == '?':
            s1 += word[i]
    for c in include_chars:
        s2 += c
    for e in s2:
        if s1.find(c) != -1:
            s1 = s1[:s1.find(c)]+s1[(s1.find(c))+1:]
        elif s1.find(c) == -1:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if (pattern[i] != '?') and (word[i] != pattern[i]):
            return False
        elif (pattern[i] == '?') and (pattern[i] in exclude_chars):
            return False
    if not include(word, pattern, include_chars):
        return False
    return True

print(match("MACMA", "M?C??", "AM", ""))
# 1662931, 2022-10-29 10:12:49, PPP-- (60%)

def include(word, pattern, include_chars):
    s1 = ''
    s2 = ''
    for i in range(len(word)):
        if pattern[i] == '?':
            s1 += word[i]
    for c in include_chars:
        s2 += c
    for e in s2:
        if s1.find(e) != -1:
            s1 = s1[:s1.find(e)]+s1[(s1.find(e))+1:]
        elif s1.find(e) == -1:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if (pattern[i] != '?') and (word[i] != pattern[i]):
            return False
        elif (pattern[i] == '?') and (pattern[i] in exclude_chars):
            return False
    if not include(word, pattern, include_chars):
        return False
    return True
exec(input()) # DON'T remove this line
# 1663407, 2022-10-29 10:24:06, ----- (0%)

def include(word, pattern, include_chars):
    s1 = ''
    s2 = ''
    for i in range(len(word)):
        if pattern[i] == '?':
            s1 += word[i]
    for c in include_chars:
        s2 += c
    for e in s2:
        if s1.find(e) != -1:
            s1 = s1[:s1.find(e)]+s1[(s1.find(e))+1:]
        elif s1.find(e) == -1:
            return False
    return True

def a(word, pattern):
    for i in range(len(word)):
        if (pattern[i] != '?') and (word[i] != pattern[i]):
            return False
    return True

def ex(word, pattern, exclude_chars):
    for i in range(len(pattern)):
        if (pattern[i] != '?') and (word[i] != pattern[i]):
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    elif not a(word, pattern):
        return False
    elif not ex(word, pattern, exclude_chars):
        return False
    return True

print(match("MACMA", "M?C??", "", "MX"))

# 1663426, 2022-10-29 10:24:33, P---- (20%)

def include(word, pattern, include_chars):
    s1 = ''
    s2 = ''
    for i in range(len(word)):
        if pattern[i] == '?':
            s1 += word[i]
    for c in include_chars:
        s2 += c
    for e in s2:
        if s1.find(e) != -1:
            s1 = s1[:s1.find(e)]+s1[(s1.find(e))+1:]
        elif s1.find(e) == -1:
            return False
    return True

def a(word, pattern):
    for i in range(len(word)):
        if (pattern[i] != '?') and (word[i] != pattern[i]):
            return False
    return True

def ex(word, pattern, exclude_chars):
    for i in range(len(pattern)):
        if (pattern[i] != '?') and (word[i] != pattern[i]):
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    elif not a(word, pattern):
        return False
    elif not ex(word, pattern, exclude_chars):
        return False
    return True

exec(input()) # DON'T remove this line

# 1663460, 2022-10-29 10:25:13, PPP-- (60%)

def include(word, pattern, include_chars):
    s1 = ''
    s2 = ''
    for i in range(len(word)):
        if pattern[i] == '?':
            s1 += word[i]
    for c in include_chars:
        s2 += c
    for e in s2:
        if s1.find(e) != -1:
            s1 = s1[:s1.find(e)]+s1[(s1.find(e))+1:]
        elif s1.find(e) == -1:
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if (pattern[i] != '?') and (word[i] != pattern[i]):
            return False
        elif (pattern[i] == '?') and (pattern[i] in exclude_chars):
            return False
    if not include(word, pattern, include_chars):
        return False
    return True
exec(input()) # DON'T remove this line

6530182121
# 1662507, 2022-10-29 10:00:02, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    a = True
    if len(word) == len(pattern) :
        for i in range (len(pattern)) :
            if pattern[i] != "?" :
                if word[i] == pattern[i] :
                    pass
                else :
                    break
                    return False
        for i in range (len(pattern)) :
            if pattern[i] == "?" :
                if not word[i] in exclude_chars :
                    pass
                else :
                    break
                    return False
        for i in range (len(include_chars)) :
            if include_chars[i] in word and pattern[i] == "?" :
                pass
            else :
                break
                return Flase
        return True
         
    else : return False
    
exec(input())

# 1662868, 2022-10-29 10:10:51, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    else :
        for i in range (len(pattern)) :
            if pattern[i] != "?" :
                if word[i] != pattern[i] :
                    return False
        for i in range (len(pattern)) :
            if pattern[i] == "?" :
                if word[i] in exclude_chars :
                    return False
        for i in range (len(include_chars)) :
            if not include_chars[i] in word  :
                return False
        return True


exec(input())

# 1664122, 2022-10-29 10:36:57, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    else :
        for i in range (len(pattern)) :
            if pattern[i] != "?" :
                if word[i] != pattern[i] :
                    return False
        for i in range (len(pattern)) :
            if pattern[i] == "?" :
                if word[i] in exclude_chars :
                    return False
        for i in range (len(include_chars)) :
            if not include_chars[i] in word  :
                return False
        return True


exec(input())

# 1664180, 2022-10-29 10:37:46, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    else :
        for i in range (len(pattern)) :
            if pattern[i] != "?" :
                if word[i] != pattern[i] :
                    return False
        for i in range (len(pattern)) :
            if pattern[i] == "?" :
                if word[i] in exclude_chars :
                    return False
        for i in range (len(include_chars)) :
            if not include_chars[i] in word  :
                return False
            return True


exec(input())

# 1664213, 2022-10-29 10:38:04, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    else :
        for i in range (len(pattern)) :
            if pattern[i] != "?" :
                if word[i] != pattern[i] :
                    return False
        for i in range (len(pattern)) :
            if pattern[i] == "?" :
                if word[i] in exclude_chars :
                    return False
        for i in range (len(include_chars)) :
            if not include_chars[i] in word  :
                return False
        return True


exec(input())

6530192421
# 1662157, 2022-10-29 09:49:18, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    s = ''
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
        if pattern[i] == '?' and word[i] in include_chars:
            s += word[i]
    if len(s) == len(include_chars):
        k = {}
        for i in s:
            if i not in k:
                k[i] = s.count(i)
        p = {}
        for i in include_chars:
            if i not in p:
                p[i] = include_chars.count(i)
        for i in k:
            if i not in p or k[i] != p[i]:
                return False
    return True
exec(input()) # DON'T remove this lin
# 1662255, 2022-10-29 09:51:53, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    s = ''
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
        if pattern[i] == '?' and word[i] in include_chars:
            s += word[i]
    if len(s) == len(include_chars):
        k = {}
        for i in s:
            if i not in k:
                k[i] = s.count(i)
        p = {}
        for i in include_chars:
            if i not in p:
                p[i] = include_chars.count(i)
        for i in k:
            if i not in p or k[i] != p[i]:
                return False
    else:
        return False
    return True
exec(input()) # DON'T remove this line
# 1664292, 2022-10-29 10:38:52, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    s = ''
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
        if pattern[i] == '?':
            if word[i] in include_chars:
                s += word[i]
            else:
                return False
    if len(s) == len(include_chars):
        k = {}
        for i in s:
            if i not in k:
                k[i] = s.count(i)
        p = {}
        for i in include_chars:
            if i not in p:
                p[i] = include_chars.count(i)
        for i in k:
            if i not in p or k[i] != p[i]:
                return False
    else:
        return False
    return True
exec(input()) # DON'T remove this line
# 1664349, 2022-10-29 10:39:23, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    s = ''
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
        if pattern[i] == '?' and word[i] in include_chars:
            s += word[i]
    if len(s) == len(include_chars):
        k = {}
        for i in s:
            if i not in k:
                k[i] = s.count(i)
        p = {}
        for i in include_chars:
            if i not in p:
                p[i] = include_chars.count(i)
        for i in k:
            if i not in p or k[i] != p[i]:
                return False
    return True
exec(input()) # DON'T remove this lin
# 1664387, 2022-10-29 10:39:43, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    s = ''
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
        if pattern[i] == '?' and word[i] in include_chars:
            s += word[i]
    if len(s) == len(include_chars):
        k = {}
        for i in s:
            if i not in k:
                k[i] = s.count(i)
        p = {}
        for i in include_chars:
            if i not in p:
                p[i] = include_chars.count(i)
        for i in k:
            if i not in p or k[i] != p[i]:
                return False
    else:
      return False
    return True
exec(input()) # DON'T remove this lin

6530210021
# 1662212, 2022-10-29 09:50:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input()) 
# 1662218, 2022-10-29 09:50:53, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input())
# 1662313, 2022-10-29 09:53:59, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    check = True
    if len(word) != len(pattern):
        check = False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            check = False
    
    
    return check
    
exec(input()) 
# 1662485, 2022-10-29 09:59:17, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    check = True
    if len(word) != len(pattern):
        check = False
        break
    else:
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                check = False
                break
            else:
                for i in range(len(word)):
                    if pattern[i] == '?' and word[i] in exclude_chars:
                        check = False
                        break
                    else:
                        for e in include_char:
                            if e not in word:
                                check = False
                            
    return check
    
exec(input()) 
# 1662542, 2022-10-29 10:01:09, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    check = True
    if len(word) != len(pattern):
        check = False       
    else:
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                check = False
                break
            else:
                for i in range(len(word)):
                    if pattern[i] == '?' and word[i] in exclude_chars:
                        check = False
                        break
                    else:
                        for e in include_chars:
                            if e not in word:
                                check = False
                            
    return check

exec(input())

6530037921
# 1663799, 2022-10-29 10:31:44, ----- (0%)

def w_p(word,pattern):
    for i in range(len(word)):
        if word[i]!=pattern[i] and\
                    pattern[i] != '?':
            return False
    return True
def not_in(word,pattern,exclude_chars):
    k1 = 0
    place= []
    while True:
        k2 = pattern.find("?",k1)
        if k2 == -1:
            break
        k1 = k2+1
        place.append(k2)
    for i in place:
        if word[i] in exclude_chars:
            return False
    return True

        
           
def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern) and\
       w_p(word,pattern)and\
       not_in(word,pattern,exclude_chars):
        return True
    else:
        return False
# 1663827, 2022-10-29 10:32:17, P--P- (40%)

def w_p(word,pattern):
    for i in range(len(word)):
        if word[i]!=pattern[i] and\
                    pattern[i] != '?':
            return False
    return True
def not_in(word,pattern,exclude_chars):
    k1 = 0
    place= []
    while True:
        k2 = pattern.find("?",k1)
        if k2 == -1:
            break
        k1 = k2+1
        place.append(k2)
    for i in place:
        if word[i] in exclude_chars:
            return False
    return True

        
           
def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern) and\
       w_p(word,pattern)and\
       not_in(word,pattern,exclude_chars):
        return True
    else:
        return False
        
exec(input()) # DON'T remove this line
# 1664095, 2022-10-29 10:36:34, P--P- (40%)

def w_p(word,pattern):
    for i in range(len(word)):
        if word[i]!=pattern[i] and\
                    pattern[i] != '?':
            return False
    return True
def not_in(word,pattern,exclude_chars):
    k1 = 0
    place= []
    while True:
        k2 = pattern.find("?",k1)
        if k2 == -1:
            break
        k1 = k2+1
        place.append(k2)
    for i in place:
        if word[i] in exclude_chars:
            return False
    return True

def same(word,pattern,include_chars):
    k1 = 0
    place= []
    sss = []
    while True:
        k2 = pattern.find("?",k1)
        if k2 == -1:
            break
        k1 = k2+1
        place.append(k2)
    for i in place:
        sss.append(i)
    for z in range(len(include_chars)):
        if include_chars[z] not in sss:
            return False
    return True
        
           
def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern) and\
       w_p(word,pattern)and\
       not_in(word,pattern,exclude_chars)and\
       same(word,pattern,include_chars):
        return True
    else:
        return False
       
exec(input()) # DON'T remove this line  
# 1664553, 2022-10-29 10:40:59, PP-P- (60%)

def w_p(word,pattern):
    for i in range(len(word)):
        if word[i]!=pattern[i] and\
                    pattern[i] != '?':
            return False
    return True
def not_in(word,pattern,exclude_chars):
    k1 = 0
    place= []
    while True:
        k2 = pattern.find("?",k1)
        if k2 == -1:
            break
        k1 = k2+1
        place.append(k2)
    for i in place:
        if word[i] in exclude_chars:
            return False
    return True

def same(word,pattern,include_chars):
    k1 = 0
    place= []
    sss = []
    while True:
        k2 = pattern.find("?",k1)
        if k2 == -1:
            break
        k1 = k2+1
        place.append(k2)
    for i in place:
        sss.append(word[i])
    for z in range(len(include_chars)):
        if include_chars[z] not in sss:
            return False
    return True
        
           
def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern) and\
       w_p(word,pattern)and\
       not_in(word,pattern,exclude_chars)and\
       same(word,pattern,include_chars):
        return True
    else:
        return False
          
exec(input()) # DON'T remove this line

6530167821
# 1661815, 2022-10-29 09:38:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] == pattern[i]:
            pass
        if word[i] == '?' :
            if word[i] in include_chars :
                pass
            elif word[i] in exclude_chars :
                return False
            

    return True
    

exec(input()) 
# 1661987, 2022-10-29 09:43:27, -P-P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] == pattern[i]:
            pass
        if pattern[i] == '?' :
            if word[i] in include_chars :
                c+= 1
            if word[i] in exclude_chars :
                return False
            
    if c != len(include_chars) :
        return False
    return True

exec(input())
# 1662107, 2022-10-29 09:47:33, -P-P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] == pattern[i]:
            pass
        elif pattern[i] == '?' :
            if word[i] in include_chars :
                c+= 1
            if word[i] in exclude_chars :
                return False
            
    if c < len(include_chars) :
        return False
    return True
exec(input())
# 1662204, 2022-10-29 09:50:30, -P-PP (60%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] == pattern[i]:
            pass
        elif pattern[i] == '?' :
            if word[i] in include_chars :
                c+= 1
            if word[i] in exclude_chars :
                return False
            
    if c < len(include_chars) :
        return False
    else  :
        for e in include_chars:
            if e not in word:
                return False
    return True
exec(input())

6530006421
# 1662021, 2022-10-29 09:44:52, PP-P- (60%)

# Quiz 2_2
# This Code was written by Folkiesss Desu!!

def match(word, pattern, include_chars, exclude_chars):

    if len(word) != len(pattern):
        return False
    elif match_patt(word, pattern):
        return False
    elif find_ex(word, pattern, exclude_chars):
        return False
    elif find_in(word, pattern, include_chars):
        return False
    
    return True

def match_patt(word, pattern):
    
    for i in range(len(pattern)):
        bo1 = True
        temp = []
        if pattern[i] == "?":
            continue
        else:
            temp.append(pattern[i] == word[i])
        if all(temp):
            return False

        return True

def find_ex(word, pattern, exclude_c):
    for i in range(len(pattern)):
        if pattern[i] != "?":
            continue
        elif word[i] in exclude_c:
            return True

    return False

def find_in(word, pattern, include_c):
    temp = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            temp.append(word[i])

    for letter in list(set(include_c)):
        if temp.count(letter) != include_c.count(letter):
            return True

    return False
        
    
exec(input()) # DON'T remove this line

# 1663781, 2022-10-29 10:31:17, x---x (0%)

# Quiz 2_2
# This Code was written by Folkiesss Desu!!

def match(word, pattern, include_chars, exclude_chars):

    if len(word) != len(pattern):
        return False
    elif match_patt(word, pattern):
        return False
    elif find_ex(word, pattern, exclude_chars):
        return False
    elif find_in(word, pattern, include_chars):
        return False
    
    return True

def match_patt(word, pattern):
    
    for i in get_idx(word, pattern):
        if word[i] != pattern[i]:
            return True
    return False

def find_ex(word, pattern, exclude_c):

    for i in range(len(word)):
        if i not in get(idx):
            if word[i] in exclude_c:
                return True

    return False

def find_in(word, pattern, include_c):
    temp = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            temp.append(word[i])

    for letter in list(set(include_c)):
        if temp.count(letter) != include_c.count(letter):
            return True

    return False

def get_idx(word, pattern):
    idx = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            idx.append(i)

    return idx
        
    
exec(input()) # DON'T remove this line

# 1664163, 2022-10-29 10:37:29, x---x (0%)

# Quiz 2_2
# This Code was written by Folkiesss Desu!!

def match(word, pattern, include_chars, exclude_chars):

    if len(word) != len(pattern):
        return False
    elif match_patt(word, pattern):
        return False
    elif find_ex(word, pattern, exclude_chars):
        return False
    elif find_in(word, pattern, include_chars):
        return False
    else:
        return True

def match_patt(word, pattern):
    
    for i in get_idx(word, pattern):
        if word[i] != pattern[i]:
            return True
    return False

def find_ex(word, pattern, exclude_c):

    for i in range(len(word)):
        if i not in get(idx):
            if word[i] in exclude_c:
                return True

    return False

def find_in(word, pattern, include_c):
    word_c = [word[i] for i in range(len(word)) if i not in get_idx(word, pattern)]
    ch = list(set(word_c))

    for x in ch:
        if word_c.count(x) != include_c.count(x):
              return True

    return False

def get_idx(word, pattern):
    idx = []
    for i in range(len(pattern)):
        if pattern[i] == "?":
            idx.append(i)

    return idx
        
    
exec(input()) # DON'T remove this line


6530176421
# 1663325, 2022-10-29 10:22:34, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    x=True
    if len(word)==len(pattern):
        for i in range(len(word)):
            if word[i]==pattern[i] or pattern[i]=='?':
                if word[i] in exclude_chars:
                    x=False
                    
            elif word[i]!=pattern[i]:
                x=False
    else:
        x=False
    return x
  

exec(input())
# 1663642, 2022-10-29 10:28:34, ---P- (20%)

def match(word, pattern, include_chars, exclude_chars):
    x=True
    check=[]
    if len(word)==len(pattern):
        for i in range(len(word)):
            if word[i]==pattern[i] or pattern[i]=='?':
                if pattern[i]=='?':
                    if word[i] in exclude_chars:
                        x=False
                elif word[i]!=pattern[i]:
                    x=False
    else:
        x=False
    return x
  

exec(input())

# 1664178, 2022-10-29 10:37:45, PP-P- (60%)

def check(w, include):
    h=[]
    for e in include:
        h.append(e)
    for e in w :
        for k in h:
            if e==k:
                h.remove(k)
    if len(h)!=0:
        return False
        

def match(word, pattern, include_chars, exclude_chars):
    x=True
    if len(word)==len(pattern):
        for i in range(len(word)):
            if word[i]==pattern[i] or pattern[i]=='?':
                if word[i] in exclude_chars:
                    x=False
                if check(word, include_chars)==False:
                    x=False
            elif word[i]!=pattern[i]:
                x=False
    else:
        x=False
    return x
exec(input())



6531317821
# 1662047, 2022-10-29 09:45:29, PP-P- (60%)

def checker(word,pattern):
    k = ""
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == "?":
            k += pattern[i]
    if k == pattern: return True
    return False
def exclude(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == "?":
            if word[i] in exclude_chars: return False
    return True
def include(word, pattern, include_chars):
    x = set()
    if len(include_chars) != 0:
        for i in range(len(word)):
            if pattern[i] == "?" and word[i] in include_chars:
                x.add(word[i])
        if x & set(include_chars) != set(include_chars): return False
        return True
    else: return True
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    if not checker(word,pattern): return False
    if not exclude(word,pattern,exclude_chars): return False
    if not include(word, pattern, include_chars): return False
    return True
exec(input()) 
# 1662113, 2022-10-29 09:47:49, PP-P- (60%)

def checker(word,pattern):
    k = ""
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == "?":
            k += pattern[i]
    if k == pattern: return True
    return False
def exclude(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == "?":
            if word[i] in exclude_chars: return False
    return True
def include(word, pattern, include_chars):
    x = set()
    if len(include_chars) != 0:
        for i in range(len(word)):
            if pattern[i] == "?" and word[i] in include_chars:
                x.add(word[i])
        if x & set(include_chars) != set(include_chars): return False
        return True
    else: return True
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    if not checker(word,pattern): return False
    if not exclude(word,pattern,exclude_chars): return False
    if not include(word, pattern, include_chars): return False
    return True
exec(input())
# 1664063, 2022-10-29 10:35:57, PP-P- (60%)

def checker(word,pattern):
    k = ""
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == "?":
            k += pattern[i]
    if k == pattern: return True
    return False
def exclude(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == "?":
            if word[i] in exclude_chars: return False
    return True
def include(word, pattern, include_chars):
    x = set()
    if len(include_chars) != 0:
        for i in range(len(word)):
            if pattern[i] == "?" and word[i] in include_chars:
                x.add(word[i])
        if x & set(include_chars) != set(include_chars): return False
        return True
    else: return True
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern): return False
    if not checker(word,pattern): return False
    if not exclude(word,pattern,exclude_chars): return False
    if not include(word, pattern, include_chars): return False
    return True
exec(input().strip())

6531324121
# 1661743, 2022-10-29 09:34:56, P--P- (40%)

def get_counter(word):
    res = {}
    for char in res:
        if char not in res:
            res[char] = 1
        else:
            res[char] += 1
    
    return res

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    word_counter = get_counter(word)
    inc_counter = get_counter(include_chars)
    for char in inc_counter:
        if char not in word_counter:
            return False
        else:
            if inc_counter[char] > word_counter[char]:
                return False

    for c, t in zip(word, pattern):
        if c != t and t != "?":
            return False
        
        else:
            if c in exclude_chars:
                return False
    
    return True

exec(input())
# 1661864, 2022-10-29 09:39:30, PP-P- (60%)

def get_counter(word):
    res = {}
    for char in word:
        if char not in res:
            res[char] = 1
        else:
            res[char] += 1
    
    return res

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    word_counter = get_counter(word)
    inc_counter = get_counter(include_chars)
    for char in inc_counter:
        if char not in word_counter:
            return False
        else:
            if inc_counter[char] > word_counter[char]:
                return False

    for c, t in zip(word, pattern):
        if c != t and t != "?":
            return False
        
        else:
            if c in exclude_chars:
                return False
    
    return True

exec(input())
# 1661902, 2022-10-29 09:40:37, PP-P- (60%)

def get_counter(word):
    res = {}
    for char in word:
        if char not in res:
            res[char] = 1
        else:
            res[char] += 1
    
    return res

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    word_counter = get_counter(word)
    inc_counter = get_counter(include_chars)
    for char in inc_counter:
        if char not in word_counter:
            return False
        else:
            if inc_counter[char] > word_counter[char]:
                return False

    for c, t in zip(word, pattern):
        if c != t and t != "?":
            return False
        
        else:
            if c in exclude_chars and t == "?":
                return False
    
    return True

exec(input())

6531342421
# 1661836, 2022-10-29 09:38:47, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):   return False
    cnt=0
    a=""
    k=0
    for i in range(len(word)):
        if word[i] == pattern[i]:
            cnt+=1
        elif pattern[i] == '?':
            cnt+=1
            a = a + word[i]
            k+=1
    if cnt != len(word):
        return False
    for i in range(len(include_chars)):
        if include_chars[i] not in a:
            return False
    for i in range(len(exclude_chars)):
        if exclude_chars[i] in a:
            return False
    return True
exec(input()) # DON'T remove this line
# 1664134, 2022-10-29 10:37:05, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):   return False
    cnt=0
    a=""
    k=0
    for i in range(len(word)):
        if word[i] == pattern[i]:
            cnt+=1
        elif pattern[i] == '?':
            cnt+=1
            a = a + word[i]
            k+=1
    if cnt != len(word):
        return False
    dic={}
    for i in a:
        if i not in dic:
            dic[i] = 1
        else:
            dic[i] +=1 
    for i in include_chars:
        if i not in a:
            return False
        dic[i] -= 1
        if dic[i] == 0:
            return False
        
    for i in range(len(exclude_chars)):
        if exclude_chars[i] in a:
            return False
    return True
exec(input()) 
# 1664166, 2022-10-29 10:37:30, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):   return False
    cnt=0
    a=""
    k=0
    for i in range(len(word)):
        if word[i] == pattern[i]:
            cnt+=1
        elif pattern[i] == '?':
            cnt+=1
            a = a + word[i]
            k+=1
    if cnt != len(word):
        return False
    for i in range(len(include_chars)):
        if include_chars[i] not in a:
            return False
    for i in range(len(exclude_chars)):
        if exclude_chars[i] in a:
            return False
    return True
exec(input()) # DON'T remove this line

6531802821
# 1662694, 2022-10-29 10:05:58, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    ls = []
    if len(word) == len(pattern) :
        for i in range(len(pattern)) :
            if pattern[i] != "?" :
                if pattern[i] != word[i] :
                    return False
            if pattern[i] == "?" :
                ls.append(word[i])
                if word[i] in exclude_chars :
                    return False
                else :
                    for k in include_chars :
                        if k in ls :
                            return True
                        else :
                            return False       
    else :
        return False  
exec(input()) # DON'T remove this line
# 1663032, 2022-10-29 10:15:31, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    ls = []
    if len(word) == len(pattern) :
        for i in range(len(pattern)) :
            if pattern[i] != "?" :
                if pattern[i] != word[i] :
                    return False
            elif pattern[i] == "?" :
                if word[i] in exclude_chars :
                    return False
                else :
                    ls.append(word[i])
                for k in include_chars :
                    if k in ls :
                        return True
                    else :
                        return False       
    else :
        return False  
exec(input()) # DON'T remove this line
# 1663207, 2022-10-29 10:19:39, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars) :
    ls = []
    c = 0
    if len(word) == len(pattern) :
        for i in range(len(pattern)) :
            if pattern[i] != "?" :
                if pattern[i] != word[i] :
                    return False
            elif pattern[i] == "?" :
                if word[i] in exclude_chars :
                    return False
                else :
                    ls.append(word[i])      
    else :
        return False
    for k in include_chars :
        if k in ls :
            c += 1
        else :
            c += 0
    if c == len(include_chars) :
        return True
    else :
        return False
exec(input()) # DON'T remove this line

6230148621
# 1664052, 2022-10-29 10:35:52, PP-P- (60%)

def match(word, pattern, include_char, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == "?":
            if word[i] in exclude_chars: return False
        elif pattern[i] != word[i]: return False
    for c in include_char:
        if c not in word: return False
        if word.count(c) < include_char.count(c):
            return False
    return True

exec(input())
# 1664066, 2022-10-29 10:36:00, PP-P- (60%)

def match(word, pattern, include_char, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == "?":
            if word[i] in exclude_chars: return False
        elif pattern[i] != word[i]: return False
    for c in include_char:
        if c not in word: return False
        if word.count(c) < include_char.count(c):
            return False
    return True

exec(input())

6530036221
# 1663533, 2022-10-29 10:26:38, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):x = False
    else : x = True
    
    if x == True:         
        for i in range(len(word)):
            if pattern[i] != "?" and \
               pattern[i] != word[i]:
                x = False
                
        for i in range(len(word)):
            if pattern[i] == "?" and word[i] in exclude_chars:
                x =False
        
        for e in include_chars:
            if e not in word: x = False
    
    return x
# 1663663, 2022-10-29 10:29:08, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):x = False
    else : x = True
    
    if x == True:         
        for i in range(len(word)):
            if pattern[i] != "?" and \
               pattern[i] != word[i]:
                x = False
                
        for i in range(len(word)):
            if pattern[i] == "?" and word[i] in exclude_chars:
                x =False
        
        for e in include_chars:
            if e not in word: x = False
    
    return x
exec(input()) # DON'T remove this line

6532142421
# 1662429, 2022-10-29 09:57:47, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ret = True
    if len(word) != len(pattern):
        return False
    
    for i in range(len(pattern)):
        if not (pattern[i] == word[i] or pattern[i] == '?'):
            return False
    
    for i in range(len(pattern)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    
    return True

    

exec(input()) # DON'T remove this line
# 1662559, 2022-10-29 10:01:47, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    ret = True
    if len(word) != len(pattern):
        return False
    
    for i in range(len(pattern)):
        if not (pattern[i] == word[i] or pattern[i] == '?'):
            return False
    
    for i in range(len(pattern)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    
    s = ''
    for i in range(len(pattern)):
        if pattern[i] == '?':
            s += word[i]
    for c in include_chars:
        if c not in s:
            return False
    
    return True

    

exec(input()) # DON'T remove this line

6530041321
# 1663185, 2022-10-29 10:19:10, PP-P- (60%)

def same(word,pattern):
    ans = True
    for i in range(len(pattern)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            ans = False
            break
    return ans

def check(word, pattern, include_chars, exclude_chars):
    ans = True
    check_in = []
    if same(word,pattern) == True:
        for i in range(len(pattern)):
            if pattern[i] == '?':
                if word[i] in list(exclude_chars):
                    ans = False
                    break
                if word[i] in list(include_chars):
                    check_in.append(word[i])
    check_in.sort()
    inc = list(include_chars)
    inc.sort()
    if check_in != inc:
        ans = False           
    return ans

def match(word, pattern, include_chars, exclude_chars):
    ans = True
    if len(word) != len(pattern):
        ans = False
    elif same(word,pattern) == False:
        ans = False
    elif check(word, pattern, include_chars, exclude_chars) == False:
        ans = False
    return ans
exec(input()) # DON'T remove this line

6530106521
# 1662092, 2022-10-29 09:46:57, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != '?' and  pattern[i] != word[i]:
            return False
    pos = []
    kam = []
    for i in range(len(pattern)):
        if pattern[i] == '?':
            pos.append(i)
            kam.append(word[i])
            if word[i] in exclude_chars:
                return False
    for e in range(len(include_chars)):
        if include_chars[e] not in kam:
            return False
    return True
    
        
exec(input())


6531301721
# 1663159, 2022-10-29 10:18:37, PP-P- (60%)

def make_list(s):
    out = []
    for c in s:
        out.append(c)
    return out
def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        ind = 0
        for i in range(len(pattern)):
            if pattern[i] == '?':
                ind += 1
            elif pattern[i] == word[i]:
                ind += 1
        if ind == len(pattern):
            for i in range(len(pattern)):
                if pattern[i] == '?':
                    if word[i] in exclude_chars:
                        return False
            l = make_list(include_chars)
            l2 = make_list(word)
            for i in range(len(make_list(include_chars))):
                if make_list(include_chars)[i] in l2:
                    l.remove(make_list(include_chars)[i])
                    l2.remove(make_list(include_chars)[i])
            if len(l) > 0:
                return False
            else:
                return True
        else:
            return False
    else:
        return False
exec(input())

6531315521
# 1662667, 2022-10-29 10:05:10, PP-P- (60%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) != len(pattern):
    return False
  a = []
  for i in range(len(word)):
    if word[i] != pattern[i] and pattern[i] != '?':
      return False
    if pattern[i] == '?':
      if word[i] in exclude_chars:
        return False
  k1 = 0
  for al in include_chars:
    if al not in word:
      return False
    k1 = word.find(al,k1)
    if pattern[i] != '?':
      return False
    k1 += 1
  return True
exec(input())

Max Score = 40


6231425621
# 1662699, 2022-10-29 10:06:06, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            else:
                L = list(include_chars)
                L.sort()
                if pattern[i] == '?':
                    if word[i] in L:
                        L.remove(word[i])
        if len(L) != 0:
            return False
  
    else:
        return False
    
    
exec(input()) 
# 1663029, 2022-10-29 10:15:28, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            else:
                L = list(include_chars)
                L.sort()
                if pattern[i] == '?':
                    if word[i] in L:
                        L.remove(word[i])
                if len(L) == 0:
                    out = True
                else:
                    out = False
        return out
  
    else:
        return False
    
    
exec(input()) 
# 1663078, 2022-10-29 10:16:16, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            else:
                return True
  
    else:
        return False
    
    
exec(input())
# 1663357, 2022-10-29 10:23:08, xxx-- (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            elif  pattern[i] == '?':
                k = word[i].find(include_chars)
                if k == -1:
                    return False
                elif k in out:
                    return False
                else:
                    k.append(word[i])
            else:
                return True
                
  
    else:
        return False
    
    
exec(input()) 

# 1663380, 2022-10-29 10:23:35, xxx-- (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            elif  pattern[i] == '?':
                k = word[i].find(include_chars)
                if k == -1:
                    return False
                elif k in out:
                    return False
                else:
                    k.append(word[i])
            else:
                return True
                
  
    else:
        return False
    
    
exec(input()) 
# 1663434, 2022-10-29 10:24:39, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    out = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            else:
              return True
                
  
    else:
        return False
    
    
exec(input())
# 1663520, 2022-10-29 10:26:22, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            elif  pattern[i] == '?':
                k = word[i].find(include_chars)
                if k == -1:
                    return False
                elif k in out:
                    return False
                else:
                    k.append(word[i])
        return True
                
  
    else:
        return False
    
    
exec(input()) 

# 1663572, 2022-10-29 10:27:21, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            elif  pattern[i] == '?':
                k = word[i].find(include_chars)
                if k == -1:
                    return False
                elif k not in out:
                    k.append(word[i])
                else:
                    return False
                    
        return True
                
  
    else:
        return False
    
    
exec(input()) 

# 1663664, 2022-10-29 10:29:08, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            elif  pattern[i] == '?':
                k = word[i].find(include_chars)
                if k == -1:
                    return False
                elif k not in out:
                    out.append(word[i])
                else:
                    return False
                    
        return True
                
  
    else:
        return False
    
    
exec(input()) 
# 1663871, 2022-10-29 10:33:10, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    out = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            elif  pattern[i] == '?':
                l = list(include_chars)
                if word[i] in l:
                    l.remove(word[i])
                
                    
        if len(l) != 0:
            return False
        else:
            return True
                
  
    else:
        return False
    
    
exec(input()) 

# 1664227, 2022-10-29 10:38:13, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            else:
                L = list(include_chars)
                L.sort()
                if pattern[i] == '?':
                    if word[i] in L:
                        L.remove(word[i])
                
        if len(L) == 0:
            out = True
        else:
            out = False    
  
    else:
        return False
    
    
exec(input())
# 1664286, 2022-10-29 10:38:49, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    out = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            elif pattern[i] =='?' and word[i] in exclude_chars:
                return False
            
            else:
                L = list(include_chars)
                L.sort()
                if pattern[i] == '?':
                    if word[i] in L:
                        L.remove(word[i])
                
        if len(L) == 0:
            return True
        else:
            return False    
  
    else:
        return False
    
    
exec(input())

6531335021
# 1662388, 2022-10-29 09:56:36, ----- (0%)

def match(word, pattern, include_chars, exclude_chars): 
    if len(word) != len(pattern) :
        return False 
    else :
        for i in range(len(word)) :
            if word[i] != pattern[i] and pattern[i] != "?" :
                return False
            if word[i] != pattern[i] and pattern[i] == "?" :
                if word[i] in exclude_chars :
                    return False
                if word[i] not in include_chars :
                    return False
    return True


exec(input()) # DON'T remove this line

# 1662820, 2022-10-29 10:09:28, ----- (0%)

def match(word, pattern, include_chars, exclude_chars): 
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            if word[i] in exclude_chars :
                return False
            if word[i] not in include_chars :
                return False
    return True
exec(input()) # DON'T remove this line

# 1663034, 2022-10-29 10:15:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    if sorted(inc) != sorted(include_chars) :
        return False
    return True
exec(input()) # DON'T remove this line

# 1663203, 2022-10-29 10:19:36, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    if sorted(inc) != sorted(include_chars) :
        return False
    return True
exec(input()) # DON'T remove this line

# 1663458, 2022-10-29 10:25:09, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    if sorted(inc) != sorted(include_chars) :
        return False
    return True
exec(input().strip()) # DON'T remove this line

# 1663583, 2022-10-29 10:27:30, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    if sorted(inc) != sorted(include_chars) :
        return False
    return True

exec(input()) # DON'T remove this line
# 1663595, 2022-10-29 10:27:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    if sorted(inc) != sorted(include_chars) :
        return False
    return True

exec(input()) 
# 1663703, 2022-10-29 10:29:59, ----- (0%)


def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    if sorted(inc) != sorted(include_chars) :
        return False
    return True

exec(input())
# 1663994, 2022-10-29 10:35:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    if sorted(inc) != sorted(include_chars) :
        return False
    return True

exec(input()) # DON'T remove this line
# 1664260, 2022-10-29 10:38:33, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    return True

exec(input()) # DON'T remove this line
# 1664508, 2022-10-29 10:40:41, ---P- (20%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    inc.sort()
    free = []
    for t in include_chars :
        free.append(t)
    free.sort()
    if inc == free :
        return False
    return True

exec(input()) # DON'T remove this line
# 1664655, 2022-10-29 10:42:11, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    inc = []
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] and pattern[i] != "?" :
            return False
        if word[i] != pattern[i] and pattern[i] == "?" :
            inc.append(word[i])
            if word[i] in exclude_chars :
                return False
    return True

exec(input()) # DON'T remove this line

6230083421
# 1662090, 2022-10-29 09:46:57, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    ex = ''
    for c in exclude_chars:
        ex += c
    if len(word) != len(pattern):
        retuen False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
            
    return True
exec(input()) 

# 1662116, 2022-10-29 09:47:53, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ex = ''
    for c in exclude_chars:
        ex += c
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
            
    return True
exec(input()) 

# 1662232, 2022-10-29 09:51:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    ex = '' ; inc = ''
    for c in exclude_chars:
        ex += c
    for c in include_chars:
        inc += c 
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
            if word[i] not in inc:
                return False
    return True
exec(input()) 

# 1662244, 2022-10-29 09:51:38, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ex = '' ; inc = ''
    for c in exclude_chars:
        ex += c
    for c in include_chars:
        inc += c 
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False

    return True
exec(input()) 

# 1662302, 2022-10-29 09:53:35, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    ex = '' ; inc = ''
    for c in exclude_chars:
        ex += c
    for c in include_chars:
        inc += c 
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
            if pattern[i] == '?' and word[i] not in inc:
                return False
                break
            
    return True
exec(input()) 

# 1662415, 2022-10-29 09:57:25, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ex = '' ; inc = ''
    for c in exclude_chars:
        ex += c
    for c in include_chars:
        inc += c 
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
            
    return True
exec(input())
# 1662782, 2022-10-29 10:08:45, compilation error (0%)

for i in range(len(word)):
# 1662803, 2022-10-29 10:09:11, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ex = '' ; inc = []
    cp = pattern.count('?')
    for c in exclude_chars:
        ex += c
    for c in include_chars:
        inc.append(c)
    if len(word) != len(pattern):
        return False
    else:
        store = []
        for i in range(len(word)):
            if pattern[i] == '?' and word[i] == pattern[i]:
                store.append(word[i])
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
        store.sort() ; inc.sort()
        if store != inc:
            return False
            
                    
            
    return True
exec(input()) 

# 1662970, 2022-10-29 10:13:59, xx-xx (0%)

def match(word, pattern, include_chars, exclude_chars):
    ex = '' ; inc = []
    cp = pattern.count('?')
    for c in exclude_chars:
        ex += c
    for c in include_chars:
        inc.append(c)
    if len(word) != len(pattern):
        return False
    else:
        store = []
        for i in range(len(word)):
            if pattern[i] == '?' and word[i] == pattern[i]:
                store.append(word[i])
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
        store.sort() ; inc.sort()
        if store != inc:
            return False
        for i in range(len(word)):
            if pattern[i] == '?' :
                inc.remove[word[i]]
        if len(inc) != 0:
            return False
    return True
exec(input()) 

# 1663019, 2022-10-29 10:15:05, xx-xx (0%)

def match(word, pattern, include_chars, exclude_chars):
    ex = '' ; inc = []
    cp = pattern.count('?')
    for c in exclude_chars:
        ex += c
    for c in include_chars:
        inc.append(c)
    if len(word) != len(pattern):
        return False
    else:
        store = []
        for i in range(len(word)):
            if pattern[i] == '?' and word[i] == pattern[i]:
                store.append(word[i])
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
        store.sort() ; inc.sort()
        if store != inc:
            return False
        for i in range(len(word)):
            if pattern[i] == '?' :
                inc.remove(word[i])
        if len(inc) != 0:
            return False
    return True
exec(input()) 

# 1663113, 2022-10-29 10:17:23, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    ex = '' ; inc = []
    cp = pattern.count('?')
    for c in exclude_chars:
        ex += c
    for c in include_chars:
        inc.append(c)
    if len(word) != len(pattern):
        return False
    else:
        store = []
        for i in range(len(word)):
            if pattern[i] == '?' and word[i] == pattern[i]:
                store.append(word[i])
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            if pattern[i] == '?' and word[i] in ex:
                return False
#         store.sort() ; inc.sort()
#         if store != inc:
#             return False
#         for i in range(len(word)):
#             if pattern[i] == '?' :
#                 inc.remove(word[i])
#         if len(inc) != 0:
#             return False
    return True
exec(input()) 


6530196021
# 1662238, 2022-10-29 09:51:31, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for j in range(len(pattern)):
        check = []
        if pattern[i] == '?':
            check.append(word[i])
    for e in exclude_chars:
        if e in check:
            return False
    for t in include_chars:
        if t not in word:
            return False
    return True
exec(input()) 
# 1662265, 2022-10-29 09:52:22, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for j in range(len(pattern)):
        check = []
        if pattern[j] == '?':
            check.append(word[j])
    for e in exclude_chars:
        if e in check:
            return False
    for t in include_chars:
        if t not in word:
            return False
    return True
exec(input())
# 1662508, 2022-10-29 10:00:03, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
      for i in range(len(word)):
          if pattern[i] != '?' and word[i] != pattern[i]:
              return False
      for j in range(len(pattern)):
          check = []
          if pattern[j] == '?':
              check.append(word[j])
      for e in exclude_chars:
          if e in check:
              return False
      for t in include_chars:
          if t not in word:
              return False
    return True
exec(input())
# 1662900, 2022-10-29 10:12:05, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            
        for j in range(len(pattern)):
            check = []
            if pattern[j] == '?':
                check.append(word[j])
        for e in exclude_chars:
            if e in check:
                return False
        
        ch = []
        for p in include_chars:
            ch.append(p)
        for u in word:
            if u in ch:
                ch.pop(ch.index(u))
            else:
                continue
        if ch != []:
            return False
    return True
exec(input())
# 1662997, 2022-10-29 10:14:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
        for j in range(len(pattern)):
            check = []
            if pattern[j] == '?':
                check.append(word[j])
        for e in exclude_chars:
            if e in check:
                return False
        ch = []
        for p in include_chars:
            ch.append(p)
        for u in word:
            if u in ch:
                ch.pop(ch.index(u))
            else:
                continue
        if ch != []:
            return False
    else:
      return True
exec(input())
# 1663060, 2022-10-29 10:15:54, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            
        for j in range(len(pattern)):
            check = []
            if pattern[j] == '?':
                check.append(word[j])
        for e in exclude_chars:
            if e in check:
                return False
        
        ch = []
        for p in include_chars:
            ch.append(p)
        for u in word:
            if u in ch:
                ch.pop(ch.index(u))
            else:
                continue
        if ch != []:
            return False
    return True
exec(input())
# 1663417, 2022-10-29 10:24:18, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            else:
                for j in range(len(pattern)):
                    check = []
                    if pattern[j] == '?':
                        check.append(word[j])
                for e in exclude_chars:
                    if e in check:
                        return False
                    else:
                        ch = []
                        for p in include_chars:
                            ch.append(p)
                        for u in word:
                            if u in ch:
                                ch.pop(ch.index(u))
                            else:
                                continue
                        if ch != []:
                            return False
        return True
exec(input())
# 1663453, 2022-10-29 10:25:00, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            else:
                for j in range(len(pattern)):
                    check = []
                    if pattern[j] == '?':
                        check.append(word[j])
                for e in exclude_chars:
                    if e in check:
                        return False
                    else:
                        ch = []
                        for p in include_chars:
                            ch.append(p)
                        for u in word:
                            if u in ch:
                                ch.pop(ch.index(u))
                            else:
                                continue
                        if ch != []:
                            return False
      return True
exec(input())
# 1663463, 2022-10-29 10:25:18, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            
        for j in range(len(pattern)):
            check = []
            if pattern[j] == '?':
                check.append(word[j])
        for e in exclude_chars:
            if e in check:
                return False
        
        ch = []
        for p in include_chars:
            ch.append(p)
        for u in word:
            if u in ch:
                ch.pop(ch.index(u))
            else:
                continue
        if ch != []:
            return False
    return True
exec(input())
# 1664118, 2022-10-29 10:36:55, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    elif a(word, pattern):
        return False
    elif b(pattern, include_chars,word,exclude_chars):
        return False
    elif c(include_chars,word):
        return False
    else:
        return True
    
def a(word, pattern):
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return True
        
def b(pattern, include_chars,word,exclude_chars):
    for j in range(len(pattern)):
        check = []
        if pattern[j] == '?':
            check.append(word[j])
    for e in exclude_chars:
        if e in check:
            return True
        
def c(include_chars,word):
    ch = []
    for p in include_chars:
        ch.append(p)
    for u in word:
        if u in ch:
            ch.pop(ch.index(u))
        else:
            continue
    if ch != []:
        return True
exec(input())
# 1664650, 2022-10-29 10:42:03, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    elif a(word, pattern):
        return False
    elif b(pattern, include_chars,word,exclude_chars):
        return False
    elif c(include_chars,word):
        return False
    else:
        return True
    
def a(word, pattern):
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return True
        
def b(pattern, include_chars,word,exclude_chars):
    for j in range(len(pattern)):
        check = []
        if pattern[j] == '?':
            check.append(word[j])
    for e in exclude_chars:
        if e in check:
            return True
        
def c(include_chars,word):
    ch = []
    for p in include_chars:
        ch.append(p)
    for u in word:
        if u in ch:
            ch.remove(u)
        else:
            continue
    if ch != []:
        return True
exec(input())

6530089521
# 1662458, 2022-10-29 09:58:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alphab= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'
    for i in word:
        if i not in alpha: return False
    for i in pattern:
        if i not in alphab: return False
    x=0
    for i in pattern:
        if i =='?': x+=1
    for i in include_chars:
        if len(include_chars)>x: return False
        if i not in alpha: return False
    for i in exclude_chars:
        if i not in alpha: return False
exec(input()) # DON'T remove this line

# 1662514, 2022-10-29 10:00:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alphab= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'
    for i in word:
        if i not in alpha: return False
    for i in pattern:
        if i not in alphab: return False
    x=0
    for i in pattern:
        if i =='?': x+=1
    for i in include_chars:
        if len(include_chars)>x: return False
        if i not in alpha: return False
    for i in exclude_chars:
        if i not in alpha: return False
    return True
exec(input()) # DON'T remove this line

# 1662704, 2022-10-29 10:06:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input()) # DON'T remove this line

# 1662718, 2022-10-29 10:06:41, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    print('True')
exec(input()) # DON'T remove this line
# 1662779, 2022-10-29 10:08:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alphab= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'
    if len(word)!= len(pattern):
        return False
    for i in word:
        if i not in alpha: return False
    for i in pattern:
        if i not in alphab: return False
    x=0
    for i in pattern:
        if i =='?': x+=1
    for i in include_chars:
        if len(include_chars)>x: return False
        if i not in alpha: return False
    for i in exclude_chars:
        if i not in alpha: return False
    return True
exec(input()) # DON'T remove this line

# 1663162, 2022-10-29 10:18:45, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alphab= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'
    if len(word)!= len(pattern):
        return False
    for i in word:
        if i not in alpha: return False
    for i in pattern:
        if i not in alphab: return False
    x=0
    for i in pattern:
        if i =='?': x+=1
    for i in include_chars:
        if len(include_chars)>x: return False
        if i not in alpha: return False
    for i in exclude_chars:
        if i not in alpha: return False
    return True
exec(input()) # DON'T remove this line
# 1663698, 2022-10-29 10:29:48, compilation error (0%)

def com(word,pattern):
    x=''
    for i in range len(word):
        if word[i]!=pattern[i]
        x+=i
    return x.sort()
def match(word, pattern, include_chars, exclude_chars):
    alpha= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alphab= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'
    if len(word)!= len(pattern):
        return False
    for i in word:
        if i not in alpha: return False
    for i in pattern:
        if i not in alphab: return False
    x=0
    for i in pattern:
        if i =='?': x+=1
    for i in include_chars:
        if len(include_chars)>x: return False
        if i not in alpha: return False
    for i in exclude_chars:
        if i not in alpha: return False
    if len(include_char)>len(com(word,pattern)): return False
    for i in include_chars:
        if i not in com(word,pattern): return False
    return True
exec(input()) # DON'T remove this line

# 1663824, 2022-10-29 10:32:12, xxxxx (0%)

def com(word,pattern):
    x=''
    for i in range (len(word)):
        if word[i]!=pattern[i]:
            x+=word[i]
    return sorted(x)
def match(word, pattern, include_chars, exclude_chars):
    alpha= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alphab= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'
    if len(word)!= len(pattern):
        return False
    for i in word:
        if i not in alpha: return False
    for i in pattern:
        if i not in alphab: return False
    x=0
    for i in pattern:
        if i =='?': x+=1
    for i in include_chars:
        if len(include_chars)>x: return False
        if i not in alpha: return False
    for i in exclude_chars:
        if i not in alpha: return False
    if len(include_char)>len(com(word,pattern)): return False
    for i in include_chars:
        if i not in com(word,pattern): return False
    return True
exec(input()) # DON'T remove this line

# 1663900, 2022-10-29 10:33:29, -P--- (20%)

def com(word,pattern):
    x=''
    for i in range (len(word)):
        if word[i]!=pattern[i]:
            x+=word[i]
    return sorted(x)
def match(word, pattern, include_chars, exclude_chars):
    alpha= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alphab= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'
    if len(word)!= len(pattern):
        return False
    for i in word:
        if i not in alpha: return False
    for i in pattern:
        if i not in alphab: return False
    x=0
    for i in pattern:
        if i =='?': x+=1
    for i in include_chars:
        if len(include_chars)>x: return False
        if i not in alpha: return False
    for i in exclude_chars:
        if i not in alpha: return False
    if len(include_chars)>len(com(word,pattern)): return False
    for i in include_chars:
        if i not in com(word,pattern): return False
    return True
exec(input()) # DON'T remove this line

# 1664087, 2022-10-29 10:36:16, -P-P- (40%)

def com(word,pattern):
    x=''
    for i in range (len(word)):
        if word[i]!=pattern[i]:
            x+=word[i]
    return sorted(x)
def match(word, pattern, include_chars, exclude_chars):
    alpha= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    alphab= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?'
    if len(word)!= len(pattern):
        return False
    for i in word:
        if i not in alpha: return False
    for i in exclude_chars:
        if i in com(word,pattern): return False
    for i in pattern:
        if i not in alphab: return False
    x=0
    for i in pattern:
        if i =='?': x+=1
    for i in include_chars:
        if len(include_chars)>x: return False
        if i not in alpha: return False
    for i in exclude_chars:
        if i not in alpha: return False
    if len(include_chars)>len(com(word,pattern)): return False
    for i in include_chars:
        if i not in com(word,pattern): return False
    return True
exec(input()) # DON'T remove this line


6530104221
# 1661232, 2022-10-29 08:59:43, ----- (0%)

x=input()
print(x)
# 1661984, 2022-10-29 09:43:25, P--P- (40%)

def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
        
    if lol.sort() == tot.sort():
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
        return True
    else:
        return False
    
exec(input())

# 1662171, 2022-10-29 09:49:46, ----- (0%)

def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
    
    lol.sort()
    tot.sort()
    
    if lol == tot:
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
        return True
    else:
        return False
    
exec(input())

# 1662296, 2022-10-29 09:53:26, ----- (0%)

# def check1(word,pattern):
#     if len(word) != len(pattern):
#         return False
#     else:
#         return True
#     
# def check2(word,pattern):
#     for i in range(len(pattern)):
#         if pattern[i] == '?':
#             continue
#         elif pattern[i] != word[i]:
#             return False
#             break
#     return True
# 
# def check3(word,pattern,exclude_chars):
#     for j in range(len(pattern)):
#         if pattern[j]=='?' and word[j] in exclude_chars:
#             return False
#     return True
# 
# def check4(word,pattern,include_chars):
#     lol = [] ; tot=[]
#     for k in range(len(pattern)):
#         if pattern[k] == '?':
#             lol.append(word[k])
#     
#     for m in include_chars:
#         tot.append(m)
#     
#     lol.sort()
#     tot.sort()
#     
#     if lol == tot:
#         return True
#     else:
#         return False
#     
# def match(word, pattern, include_chars, exclude_chars):
#     if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
#         return True
#     else:
#         return False
#     
# exec(input())


def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
        
    lol.sort()
    tot.sort()
        
    if lol == tot:
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
        return True
    else:
        return False
    
exec(input())

# 1662316, 2022-10-29 09:54:03, ----- (0%)

# def check1(word,pattern):
#     if len(word) != len(pattern):
#         return False
#     else:
#         return True
#     
# def check2(word,pattern):
#     for i in range(len(pattern)):
#         if pattern[i] == '?':
#             continue
#         elif pattern[i] != word[i]:
#             return False
#             break
#     return True
# 
# def check3(word,pattern,exclude_chars):
#     for j in range(len(pattern)):
#         if pattern[j]=='?' and word[j] in exclude_chars:
#             return False
#     return True
# 
# def check4(word,pattern,include_chars):
#     lol = [] ; tot=[]
#     for k in range(len(pattern)):
#         if pattern[k] == '?':
#             lol.append(word[k])
#     
#     for m in include_chars:
#         tot.append(m)
#     
#     lol.sort()
#     tot.sort()
#     
#     if lol == tot:
#         return True
#     else:
#         return False
#     
# def match(word, pattern, include_chars, exclude_chars):
#     if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
#         return True
#     else:
#         return False
#     
# exec(input())


def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
        
    lol.sort()
    tot.sort()
        
    if lol == tot:
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
        print(True)
    else:
        print(False)
    
exec(input())

# 1662501, 2022-10-29 09:59:43, ----- (0%)

def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
        
    lol.sort()
    tot.sort()
        
    if lol == tot:
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
        return True
    else:
        return False
    
exec(input())
# 1663091, 2022-10-29 10:16:30, ----- (0%)

def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
        
    lol.sort()
    tot.sort()
        
    if lol == tot:
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    
    if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
        return False
    else:
        return True
    
exec(input())

# 1663838, 2022-10-29 10:32:35, ----- (0%)

def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
        
    lol.sort()
    tot.sort()
        
    if lol == tot:
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    return(check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars))
    
exec(input())

# 1663918, 2022-10-29 10:33:48, ----- (0%)

def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
        
    lol.sort()
    tot.sort()
        
    if lol == tot:
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    return(check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars))
    
exec(input().strip())

# 1664245, 2022-10-29 10:38:26, ----- (0%)

def check1(word,pattern):
    if len(word) != len(pattern):
        return False
    else:
        return True
    
def check2(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] == '?':
            continue
        elif pattern[i] != word[i]:
            return False
            break
    return True

def check3(word,pattern,exclude_chars):
    for j in range(len(pattern)):
        if pattern[j]=='?' and word[j] in exclude_chars:
            return False
    return True

def check4(word,pattern,include_chars):
    lol = [] ; tot=[]
    for k in range(len(pattern)):
        if pattern[k] == '?':
            lol.append(word[k])
    
    for m in include_chars:
        tot.append(m)
        
    lol.sort()
    tot.sort()
        
    if tot in lol:
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    if check1(word,pattern) and check2(word,pattern) and check3(word,pattern,exclude_chars) and check4(word,pattern,include_chars):
        return True
    else:
        return False
    
exec(input().strip())


6431007121
# 1661878, 2022-10-29 09:39:46, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):

    return True
# 1661886, 2022-10-29 09:40:05, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):

    return False
# 1662944, 2022-10-29 10:13:12, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range (len(pattern)):
        if pattern[i] !='?':
            if pattern[i] != word[i]:
                return False
    return True
# 1663015, 2022-10-29 10:14:58, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range (len(pattern)):
        if pattern[i] !='?':
            if pattern[i] != word[i]:
                return False
    return True
exec(input()) # DON'T remove this line
# 1663061, 2022-10-29 10:15:56, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range (len(pattern)):
        if pattern[i] !='?':
            if pattern[i] != word[i]:
                return False
    return False
exec(input()) # DON'T remove this line
# 1663076, 2022-10-29 10:16:15, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range (len(pattern)):
        if pattern[i] !='?':
            if pattern[i] != word[i]:
                return False
    return True
exec(input()) # DON'T remove this line
# 1664238, 2022-10-29 10:38:20, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):

    if len(word)!=len(pattern):
        return False
    d=[]
    for i in range(len(pattern)):
        if pattern[i]=='?':
            d.append(word[i])
    for i in range (len(pattern)):
        if pattern[i] !='?':
            if pattern[i] != word[i]:
                return False
    for i in range(len(include_chars)):
        if include_chars[i] not in d:
            return False
    for i in range(len(exclude_chars)):
        if exclude_chars in d:
            return False
    return True
    
exec(input()) # DON'T remove this line
# 1664272, 2022-10-29 10:38:40, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):

    if len(word)!=len(pattern):
        return False
    d=[]
    for i in range(len(pattern)):
        if pattern[i]=='?':
            d.append(word[i])
    for i in range (len(pattern)):
        if pattern[i] !='?':
            if pattern[i] != word[i]:
                return False
    for i in range(len(include_chars)):
        if include_chars[i] not in d:
            return True
    for i in range(len(exclude_chars)):
        if exclude_chars in d:
            return False
    return True
    
exec(input()) # DON'T remove this line
# 1664291, 2022-10-29 10:38:52, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):

    if len(word)!=len(pattern):
        return False
    d=[]
    for i in range(len(pattern)):
        if pattern[i]=='?':
            d.append(word[i])
    for i in range (len(pattern)):
        if pattern[i] !='?':
            if pattern[i] != word[i]:
                return False
    for i in range(len(include_chars)):
        if include_chars[i] not in d:
            return False
    for i in range(len(exclude_chars)):
        if exclude_chars in d:
            return False
    return True
    
exec(input()) # DON'T remove this line

6530101321
# 1662661, 2022-10-29 10:04:55, ---P- (20%)

def match(word, pattern, include_chars, exclude_chars) :
    include = []
    exclude = []
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if word[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return False
    return True

exec(input()) # DON'T remove this line
# 1663252, 2022-10-29 10:20:50, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    include = [""]
    exclude = [""]
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return True
        else : return False

exec(input()) # DON'T remove this line
# 1663259, 2022-10-29 10:21:01, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    include = [""]
    exclude = [""]
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return True
        else : return False

exec(input()) # DON'T remove this line
# 1663275, 2022-10-29 10:21:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    include = [""]
    exclude = [""]
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return False
        else : return False

exec(input()) # DON'T remove this line
# 1663295, 2022-10-29 10:21:51, -PP-- (40%)

def match(word, pattern, include_chars, exclude_chars) :
    include = [""]
    exclude = [""]
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return False
        else : return False
    return True

exec(input()) # DON'T remove this line
# 1663303, 2022-10-29 10:22:03, -PP-- (40%)

def match(word, pattern, include_chars, exclude_chars) :
    include = [""]
    exclude = [""]
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return True
        else : return False
    return True

exec(input()) # DON'T remove this line
# 1663324, 2022-10-29 10:22:33, -PP-- (40%)

def match(word, pattern, include_chars, exclude_chars) :
    include = [""]
    exclude = [""]
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return False
        else : return True
    return True

exec(input()) # DON'T remove this line
# 1664165, 2022-10-29 10:37:30, -PP-- (40%)

def match(word, pattern, include_chars, exclude_chars) :
    include = [""]
    exclude = [""]
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return False
    return True

exec(input()) # DON'T remove this line
# 1664288, 2022-10-29 10:38:49, -PP-- (40%)

def match(word, pattern, include_chars, exclude_chars) :
    include = [""]
    exclude = [""]
    if len(word) != len(pattern) : return False
    for i in range(len(word)) :
        if pattern[i] == "?" :
            include.append(word[i])
        else :
            exclude.append(word[i])
    if include_chars == "" : return True
    for x in include_chars :
        if x in include :
            i = include.index(x)
            include.pop(i)
        else : return False
    for x in exclude_chars :
        if x in exclude : return False
    return True

exec(input()) # DON'T remove this line

6230141121
# 1663716, 2022-10-29 10:30:14, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    ex = exclude_chars
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?' :
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in ex :
                return False

exec(input())
# 1663755, 2022-10-29 10:30:48, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars):
    ex = exclude_chars
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?' :
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in ex :
                return False
    return True

exec(input())
# 1664036, 2022-10-29 10:35:41, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    ex = exclude_chars
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?' :
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in ex :
                return False
    for i in range(len(word)):
        if pattern[i] != '?' :
            if word[i] not in include_chars:
                return False
                
    return True

exec(input())
# 1664109, 2022-10-29 10:36:46, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    ex = exclude_chars
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?' :
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in ex :
                return False
    for i in range(len(word)):
        if pattern[i] == '?' :
            if word[i] not in include_chars:
                return False
                
    return True

exec(input())
# 1664153, 2022-10-29 10:37:19, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars):
    ex = exclude_chars
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?' :
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in ex :
                return False

                
    return True

exec(input())
# 1664579, 2022-10-29 10:41:16, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    ex = exclude_chars
    inn = include_chars
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?' :
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in ex :
                return False
            if word[i] not in inn :
                return False
                
    return True
# 1664601, 2022-10-29 10:41:29, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    ex = exclude_chars
    inn = include_chars
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?' :
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in ex :
                return False

    return True
# 1664622, 2022-10-29 10:41:42, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars):
    ex = exclude_chars
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != word[i] and pattern[i] != '?' :
            return False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] in ex :
                return False

                
    return True

exec(input())

6431112321
# 1662903, 2022-10-29 10:12:08, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    if word[i] != pattern[i] and pattern[i] != '?':
        return False





exec(input()) # DON'T remove this line
x[i][0] == x[i-1][0]
# 1662908, 2022-10-29 10:12:19, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    if word[i] != pattern[i] and pattern[i] != '?':
        return False
exec(input()) # DON'T remove this line
# 1663094, 2022-10-29 10:16:38, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            return False
        if pattern[i] == '?' and word[i] in exclude_chars :
            return False





exec(input()) # DON'T remove this line
# 1663121, 2022-10-29 10:17:36, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            return False
        if pattern[i] == '?' and word[i] in exclude_chars :
            return False
    return True
exec(input()) # DON'T remove this line
# 1663304, 2022-10-29 10:22:05, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            return False
        if pattern[i] == '?' and word[i] in exclude_chars :
            return False
        if pattern[i] == '?' and word[i] not in include_chars :
            return False
    return True
exec(input()) # DON'T remove this line
# 1663313, 2022-10-29 10:22:13, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            return False
        if pattern[i] == '?' and word[i] in exclude_chars :
            return False
    return True
exec(input()) # DON'T remove this line
# 1664234, 2022-10-29 10:38:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            return False
        if pattern[i] == '?' and word[i] in exclude_chars :
            return False
    return False
exec(input()) # DON'T remove this line
# 1664259, 2022-10-29 10:38:32, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            return False
        if pattern[i] == '?' and word[i] in exclude_chars :
            return False
    return True
exec(input()) # DON'T remove this line

6530027621
# 1662413, 2022-10-29 09:57:22, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    ans = True
    if len(word) != len(pattern):
        ans = False
        return ans
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            ans = False
            return ans
    word2 = []
    for k in word:
        word2.append(k)
    for e in range(len(word)):
        if word2[e] == pattern[e]:
            word2.remove(word2[e])
    for t in word2:
        if t in exclude_chars:
            ans = False
            return ans
    word3 = []
    cha = []
    for c in include_chars:
        cha.append(c)
    for u in word:
        word3.append(u)
    for s in range(len(word3)):
        if word3[s] == pattern[s]:
            word3.remove(word3[s])
    pl = len(include_chars)
    while len(cha) != 0 :
        if cha[0] in word3:
            if len(word3) == 0 and len(cha) != 0:
                ans = False
                return ans
            else:
                word3.remove(cha[0])
                cha.remove(cha[0])
    return ans
            
exec(input())  # DON'T remove this line
    

# 1662547, 2022-10-29 10:01:21, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    ans = True
    if len(word) != len(pattern):
        ans = False
        return print(ans)
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            ans = False
            return print(ans)
    #-------------------
    word2 = []
    for k in word:
        word2.append(k)
    for e in range(len(word)):
        if word2[e] == pattern[e]:
            word2.remove(word2[e])
    for t in word2:
        if t in exclude_chars:
            ans = False
            return ans
    word3 = []
    cha = []
    for c in include_chars:
        cha.append(c)
    for u in word:
        word3.append(u)
    for s in range(len(word3)):
        if word3[s] == pattern[s]:
            word3.remove(word3[s])
    pl = len(include_chars)
    while len(cha) != 0 :
        if cha[0] in word3:
            if len(word3) == 0 and len(cha) != 0:
                ans = False
                return ans
            else:
                word3.remove(cha[0])
                cha.remove(cha[0])
    return print(ans)
            
exec(input())  # DON'T remove this line
# 1662806, 2022-10-29 10:09:12, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    ans = True
    if len(word) != len(pattern):
        ans = False
        return ans
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            ans = False
            return ans
    #-------------------
    word2 = []
    for k in word:
        word2.append(k)
    for e in range(len(word2)):
        if word2[e] != pattern[e] and pattern[e] != '?':
            ans = False
            return ans
    return ans
# 1662836, 2022-10-29 10:10:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            ans = False
            return False
    #-------------------
    word2 = []
    for k in word:
        word2.append(k)
    for e in range(len(word2)):
        if word2[e] != pattern[e] and pattern[e] != '?':
            return False
    return True
# 1663039, 2022-10-29 10:15:37, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            ans = False
            return False
    #-------------------
    word2 = []
    for k in word:
        word2.append(k)
    for e in range(len(word2)):
        if word2[e] != pattern[e] and pattern[e] != '?':
            return False
    return True
    
exec(input())  # DON'T remove this line
# 1663228, 2022-10-29 10:20:02, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            ans = False
            return False
    #-------------------
    word2 = []
    for k in word:
        word2.append(k)
    for e in range(len(word2)):
        if word2[e] != pattern[e] and pattern[e] != '?':
            return False
        
    for t in range(len(word2)):
        if word[t] == '?' and word[t] in exclude_chars:
            return False
    return True
    
exec(input())  # DON'T remove this line
# 1663302, 2022-10-29 10:22:02, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            ans = False
            return False
    #-------------------
    word2 = []
    for k in word:
        word2.append(k)
    for e in range(len(word2)):
        if word2[e] != pattern[e] and pattern[e] != '?':
            return False
        
    for t in range(len(word2)):
        if pattern[t] == '?' and word[t] in exclude_chars:
            return False
    return True
    
exec(input())  # DON'T remove this line
# 1664524, 2022-10-29 10:40:47, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and pattern[i] != '?':
            ans = False
            return False
    #-------------------
    word2 = []
    for k in word:
        word2.append(k)
    for e in range(len(word2)):
        if word2[e] != pattern[e] and pattern[e] != '?':
            return False
        
    for t in range(len(word2)):
        if pattern[t] == '?' and word[t] in exclude_chars:
            return False

    
    #---------------------------

    word3 = []
    cha = []
    patternl = []
    if len(include_chars) == 0:
        return True
    for c in include_chars:
        cha.append(c)
    for u in word:
        word3.append(u)
    for h in pattern:
        if h != '?':
            patternl.append(h)
    for hk in patternl:
        word3.remove(hk)
    while len(cha) == 0 :
        for ds in range(len(word3)):
            if len(word3) == 0 and len(cha) != 0:
                return False
            if cha[0] == word3[ds]:
                word3.remove(word3[ds])
                cha.remove[0]

    return True
    
exec(input())  # DON'T remove this line

6530047121
# 1662128, 2022-10-29 09:48:20, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word)!=len(pattern):
        return False

exec(input())

# 1662147, 2022-10-29 09:49:04, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        return True
exec(input())

# 1662446, 2022-10-29 09:58:18, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not pattern[i]=="?" and not pattern[i]==word[i]:
            return False
        else:
            pass
    for j in range(len(word)):
        if pattern[i]=="?" and word[i] in exclude_chars:
            return False
    else:
        return True
exec(input())

# 1662642, 2022-10-29 10:04:24, compilation error (0%)

def match(word,pattern,include_chars,exclude_chars):
    b=""
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not pattern[i]=="?" and not pattern[i]==word[i]:
            return False
        else:
            pass
    for j in range(len(word)):
        if pattern[i]=="?" and word[i] in exclude_chars:
            return False
    for k in range len(word):
        if pattern[i]=="?":
            b+=word[i]
        if not include_chars in b:
            return False
    else:
        return True
exec(input())

# 1662662, 2022-10-29 10:04:59, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    b=""
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not pattern[i]=="?" and not pattern[i]==word[i]:
            return False
        else:
            pass
    for j in range(len(word)):
        if pattern[i]=="?" and word[i] in exclude_chars:
            return False
    for k in range(len(word)):
        if pattern[i]=="?":
            b+=word[i]
        if not include_chars in b:
            return False
    else:
        return True
exec(input())

# 1662948, 2022-10-29 10:13:18, xxxxx (0%)

def match(word,pattern,include_chars,exclude_chars):
    b=""
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not pattern[i]=="?" and not pattern[i]==word[i]:
            return False
        else:
            pass
    for j in range(len(word)):
        if pattern[i]=="?" and word[i] in exclude_chars:
            return False
    for k in range(len(word)):
        if not include_chars[k] in word:
            return False
#         if pattern[k]=="?":
#             b+=word[k]
#         if not include_chars() in b:
#             return False

    else:
        return True
exec(input())

# 1662988, 2022-10-29 10:14:23, xxxxx (0%)

def match(word,pattern,include_chars,exclude_chars):
    b=""
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not pattern[i]=="?" and not pattern[i]==word[i]:
            return False
        else:
            pass
    for j in range(len(word)):
        if pattern[i]=="?" and word[i] in exclude_chars:
            return False
    for k in range(len(word)):
        if not include_chars[k] in word:
            return False
    else:
        return True
exec(input())

# 1663049, 2022-10-29 10:15:46, PP--- (40%)

def match(word,pattern,include_chars,exclude_chars):
    b=""
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if not pattern[i]=="?" and not pattern[i]==word[i]:
            return False
        else:
            pass
    for j in range(len(word)):
        if pattern[i]=="?" and word[i] in exclude_chars:
            return False
    for k in range(len(include_chars)):
        if not include_chars[k] in word:
            return False
#         if pattern[k]=="?":
#             b+=word[k]
#         if not include_chars() in b:
#             return False

    else:
        return True
exec(input())


6530143721
# 1661999, 2022-10-29 09:44:04, xxxxx (0%)

def match(word,pattern,include_chars,exclude_chars):
    ans = False
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != '?':
                if pattern[i] == word[i]:
                    ans = True
            else:
                if word[i] not in exclude_chars and word[i] in include_chars:
                    ans = True
    return ans

print(a)
# 1662007, 2022-10-29 09:44:20, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    ans = False
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != '?':
                if pattern[i] == word[i]:
                    ans = True
            else:
                if word[i] not in exclude_chars and word[i] in include_chars:
                    ans = True
    return ans

exec(input()) 
# 1662055, 2022-10-29 09:45:49, compilation error (0%)

def match(word,pattern,include_chars,exclude_chars):
  ans = False
    if len(word) == len(pattern):
      for i in range(len(pattern)):
        if pattern[i] != '?':
          if pattern[i] == word[i]:
            ans = True
          else:
            if word[i] not in exclude_chars and word[i] in include_chars:
              ans = True
  return ans

exec(input())
# 1662076, 2022-10-29 09:46:26, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    ans = False
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != '?':
                if pattern[i] == word[i]:
                    ans = True
            else:
                if word[i] not in exclude_chars and word[i] in include_chars:
                    ans = True
    return ans

exec(input())
# 1662180, 2022-10-29 09:49:59, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
  return True
exec(input())
# 1662189, 2022-10-29 09:50:06, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
  return False
exec(input())
# 1662240, 2022-10-29 09:51:36, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    ans = False
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != '?':
                if pattern[i] == word[i]:
                    ans = True
            
    return ans
exec(input())

# 1662349, 2022-10-29 09:55:17, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars):
    ans = False
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != '?':
                if pattern[i] == word[i]:
                    ans = True
            else:
                if word[i] not in exclude_chars and include_chars in word[i]:
                    ans = True
                else:
                    return False
    return ans            
                    
            
            
  
exec(input())


6531305221
# 1662553, 2022-10-29 10:01:32, compilation error (0%)

def match(word, pattern, include, exclude):
    bool = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                pass
            elif word[i] != pattern[i]:
                bool = False
                return bool

    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude:
            return False
    in2 = list(include)
    y = []
    for i in range(len(word)):
        if pattern[i] == '?':
            y.append(word[i])

    if len(in2) == len(y) and sorted(in2) == sorted(y):
        return True
    elif len(in2) < len(y) and sorted(in2) == sorted(y[0:len(in2)+1]):
        return True
    elif:
        return False


print(match("MACMA", "M?C??", "AM", ""))

# 1662574, 2022-10-29 10:02:17, ----- (0%)

def match(word, pattern, include, exclude):
    bool = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                pass
            elif word[i] != pattern[i]:
                bool = False
                return bool

    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude:
            return False
    in2 = list(include)
    y = []
    for i in range(len(word)):
        if pattern[i] == '?':
            y.append(word[i])

    if len(in2) == len(y) and sorted(in2) == sorted(y):
        return True
    elif len(in2) < len(y) and sorted(in2) == sorted(y[0:len(in2)+1]):
        return True
    else:
        return False


print(match("MACMA", "M?C??", "AM", ""))
# 1663137, 2022-10-29 10:18:00, x---x (0%)

def match(word, pattern, include, exclude):
    bool = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                pass
            elif word[i] != pattern[i]:
                bool = False
                return bool

    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude:
            return False
    in2 = list(include)
    y = []



exec(input()) # DON'T remove this line
# 1663220, 2022-10-29 10:19:53, x--Px (20%)

def match(word, pattern, include, exclude):
    bool = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                pass
            elif word[i] != pattern[i]:
                bool = False
                return bool

    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude:
            return False
    in2 = list(include)
    y = []

    return bool

exec(input()) # DON'T remove this line
# 1663806, 2022-10-29 10:31:54, xP-Px (40%)

def match(word, pattern, include, exclude):
    bool = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                pass
            elif word[i] != pattern[i]:
                bool = False
                return bool

    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude:
            return False
    in2 = {}
    w = []
    w2 = {}
    for i in include:
        if i not in in2:
            in2.update({i: 1})
        else:
            in2[i] += 1
    for i in range(len(pattern)):
        if pattern[i] == '?':
            w.append(word[i])

    for i in w:
        if i not in w2:
            w2.update({i: 1})
        else:
            w2[i] += 1

    for k in in2:
        if k in w2:
            in2[k] -= w2[k]

        elif k not in w2:
            return False

    for i in in2:
        if in2[i] != 0:
            return False
    return True


exec(input())
# 1664394, 2022-10-29 10:39:45, xP-Px (40%)

def match(word, pattern, include, exclude):
    bool = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                pass
            elif word[i] != pattern[i]:
                bool = False
                return bool

    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude:
            return False

    if len(include)==0:
        return True
    else:
        in2 = {}
        w = []
        w2 = {}
        for i in include:
            if i not in in2:
                in2.update({i: 1})
            else:
                in2[i] += 1

        for i in range(len(pattern)):
            if pattern[i] == '?':
                w.append(word[i])

        for i in w:
            if i not in w2:
                w2.update({i: 1})
            else:
                w2[i] += 1

        for k in in2:
            if k in w2:
                in2[k] -= w2[k]

            elif k not in w2:
                return False

        for i in in2:
            if in2[i] != 0:
                return False
        return True


exec(input())
# 1664615, 2022-10-29 10:41:37, -P-P- (40%)

def match(word, pattern, include, exclude):
    try:
        bool = True
        if len(word) == len(pattern):
            for i in range(len(word)):
                if pattern[i] == '?':
                    pass
                elif word[i] != pattern[i]:
                    bool = False
                    return bool

        for i in range(len(word)):
            if pattern[i] == '?' and word[i] in exclude:
                return False

        if len(include)==0:
            return True
        else:
            in2 = {}
            w = []
            w2 = {}
            for i in include:
                if i not in in2:
                    in2.update({i: 1})
                else:
                    in2[i] += 1

            for i in range(len(pattern)):
                if pattern[i] == '?':
                    w.append(word[i])

            for i in w:
                if i not in w2:
                    w2.update({i: 1})
                else:
                    w2[i] += 1

            for k in in2:
                if k in w2:
                    in2[k] -= w2[k]

                elif k not in w2:
                    return False

            for i in in2:
                if in2[i] != 0:
                    return False
            return True
    except:
        return True


exec(input())

# 1664638, 2022-10-29 10:41:55, -P-P- (40%)

def match(word, pattern, include, exclude):
    try:
        bool = True
        if len(word) == len(pattern):
            for i in range(len(word)):
                if pattern[i] == '?':
                    pass
                elif word[i] != pattern[i]:
                    bool = False
                    return bool

        for i in range(len(word)):
            if pattern[i] == '?' and word[i] in exclude:
                return False

        if len(include)==0:
            return True
        else:
            in2 = {}
            w = []
            w2 = {}
            for i in include:
                if i not in in2:
                    in2.update({i: 1})
                else:
                    in2[i] += 1

            for i in range(len(pattern)):
                if pattern[i] == '?':
                    w.append(word[i])

            for i in w:
                if i not in w2:
                    w2.update({i: 1})
                else:
                    w2[i] += 1

            for k in in2:
                if k in w2:
                    in2[k] -= w2[k]

                elif k not in w2:
                    return False

            for i in in2:
                if in2[i] != 0:
                    return False
            return True
    except:
        return False


exec(input())

6531330921
# 1662149, 2022-10-29 09:49:08, PxxPx (40%)

def match(word,pattern,include_chars,exclude_chars):
    qpos = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                qpos.append(i)
                continue
            if pattern[i] != word[i]:
                return False
        for e in qpos:
            if word[e] in exclude_chars:
                return False
        if len(include_chars) == 0:
            return True
        i,j = 0,0
        while True:
            if len(qpos) == 0:
                return True
            if include_chars[i] == word[qpos[j]]:
                qpos.remove(qpos[j])
                i,j = 0,0
                continue
            if j >= len(qpos):
                return False
            if i >= len(include_chars):
                return False
            i += 1
    else:
        return False

exec(input())
# 1662226, 2022-10-29 09:51:12, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars):
    qpos = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                qpos.append(i)
                continue
            if pattern[i] != word[i]:
                return False
        for e in qpos:
            if word[e] in exclude_chars:
                return False
        if len(include_chars) == 0:
            return True
        i,j = 0,0
        while True:
            if len(qpos) == 0:
                return True
            if word[qpos[j]] in include_chars:
                qpos.remove(qpos[j])
                i,j = 0,0
                continue
            if j >= len(qpos):
                return False
            if i >= len(include_chars):
                return False
            i += 1
    else:
        return False

exec(input())
# 1662314, 2022-10-29 09:54:00, PTTPT (40%)

def match(word,pattern,include_chars,exclude_chars):
    qpos = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                qpos.append(i)
                continue
            if pattern[i] != word[i]:
                return False
        for e in qpos:
            if word[e] in exclude_chars:
                return False
        if len(include_chars) == 0:
            return True
        i,j = 0,0
        while True:
            if len(qpos) == 0:
                return True
            if word[qpos[j]] in include_chars:
                qpos.remove(qpos[j])
                i,j = 0,0
                continue
            else:
                pass
    else:
        return False

exec(input())
# 1663976, 2022-10-29 10:34:44, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars):
    qpos = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                qpos.append(i)
                continue
            if pattern[i] != word[i]:
                return False
        for e in qpos:
            if word[e] in exclude_chars:
                return False
        if len(include_chars) == 0:
            return True
        i,j = 0,0
        while True:
            if len(qpos) == 0:
                return True
            if word[qpos[j]] in include_chars:
                qpos.remove(qpos[j])
                i,j = 0,0
                continue
            if j >= len(qpos):
                return False
            if i >= len(include_chars):
                return False
            i += 1
    else:
        return False

exec(input())
# 1664094, 2022-10-29 10:36:33, PxxPx (40%)

def match(word,pattern,include_chars,exclude_chars):
    qpos = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                qpos.append(i)
                continue
            if pattern[i] != word[i]:
                return False
        for e in qpos:
            if word[e] in exclude_chars:
                return False
        if len(include_chars) == 0:
            return True
        i,j = 0,0
        while True:
            if len(qpos) == 0:
                return True
            if include_chars[i] in word:
                word = word[:word.find(include_chars)]+word[word.find(include_chars)+1:]
                i+=1
            else:
                return False
    else:
        return False

exec(input())
# 1664146, 2022-10-29 10:37:12, PxxPx (40%)

def match(word,pattern,include_chars,exclude_chars):
    qpos = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                qpos.append(i)
                continue
            if pattern[i] != word[i]:
                return False
        for e in qpos:
            if word[e] in exclude_chars:
                return False
        if len(include_chars) == 0:
            return True
        i,j = 0,0
        while True:
            if len(include_chars) == 0:
                return True
            if include_chars[i] in word:
                word = word[:word.find(include_chars)]+word[word.find(include_chars)+1:]
                i+=1
            else:
                return False
    else:
        return False

exec(input())
# 1664190, 2022-10-29 10:37:51, PxxPx (40%)

def match(word,pattern,include_chars,exclude_chars):
    qpos = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                qpos.append(i)
                continue
            if pattern[i] != word[i]:
                return False
        for e in qpos:
            if word[e] in exclude_chars:
                return False
        if len(include_chars) == 0:
            return True
        i,j = 0,0
        while True:
            if len(include_chars) == 0:
                return True
            if include_chars[i] in word:
                word = word[:word.find(include_chars[i])]+word[word.find(include_chars[i])+1:]
                i+=1
            else:
                return False
    else:
        return False

exec(input())
# 1664348, 2022-10-29 10:39:23, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars):
    qpos = []
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                qpos.append(i)
                continue
            if pattern[i] != word[i]:
                return False
        for e in qpos:
            if word[e] in exclude_chars:
                return False
        if len(include_chars) == 0:
            return True
        i = 0
        while True:
            if i >= len(include_chars):
                return False
            if len(include_chars) == 0:
                return True
            if include_chars[i] in word:
                word = word[:word.find(include_chars[i])]+word[word.find(include_chars[i])+1:]
                i = 0
            else:
                i += 1
    else:
        return False

exec(input())

6530024721
# 1661718, 2022-10-29 09:33:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    return True
exec(input()) # DON'T remove this line
# 1661843, 2022-10-29 09:39:01, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if  len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] == pattern[i] and pattern[i] != '?' and ( not (word[i] in exclude_chars)) and (word[i] in include_chars) :
            c += 1
    return c == len(word)        
exec(input()) # DON'T remove this line
# 1662166, 2022-10-29 09:49:30, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if  len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] == '?' :
            c += 1
        else :
            if word[i] == pattern[i] and (not (word[i] in exclude_chars)):
                if exclude_chars in word[i] :
                    c += 1
    return c == len(word)        
exec(input()) # DON'T remove this line
# 1662470, 2022-10-29 09:58:53, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if  len(word) != len(pattern) :
        return False
    f = True
    d = 0
    for e in include_chars :
        if e in word :
            d += 1
    if d == len(include_chars) :
        for i in range(len(word)) :
            if pattern[i] == '?' :
                c += 1
            else :
                if word[i] == pattern[i] and (not (word[i] in exclude_chars)):
                    c += 1 
    return c == len(word)        
exec(input()) # DON'T remove this line
# 1662530, 2022-10-29 10:00:47, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if  len(word) != len(pattern) :
        return False
    f = True
    d = 0
    for e in include_chars :
        if e in word :
            d += 1
    if d == len(include_chars) :
        for i in range(len(word)) :
            if pattern[i] == '?' and not(pattern[i] in exclude_chars)  :
                c += 1
            else :
                if word[i] == pattern[i] :
                    c += 1 
    return c == len(word)        
exec(input()) # DON'T remove this line
# 1662593, 2022-10-29 10:02:51, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if  len(word) != len(pattern) :
        return False
    f = True
    d = 0
    for e in include_chars :
        if e in word :
            d += 1
    if d == len(include_chars) :
        for i in range(len(word)) :
            if pattern[i] == '?' and not(pattern[i] in exclude_chars)  :
                c += 1
            else :
                if word[i] == pattern[i] :
                    c += 1 
    return c == len(word)        
exec(input()) # DON'T remove this line
# 1664110, 2022-10-29 10:36:47, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if  len(word) != len(pattern) :
        return False
    f = True
    d = check(word,include_chars)
    #for e in include_chars :
     #   if e in word :
      #      d += 1
    if d == True :
        for i in range(len(word)) :
            if pattern[i] == '?' and not(pattern[i] in exclude_chars)  :
                c += 1
            else :
                if word[i] == pattern[i]:
                    c += 1 
    return c == len(word)        

def check(w,i) :
    ww = []
    ii = []
    c = 0
    for e in w :
        ww.append(e)
    for e in i :
        ii.append(e)
    for e in ii :
        if e in ww :
            c += 1
            ww.remove(e)
    return c == len(i)
    

exec(input()) # DON'T remove this line

6530032721
# 1662351, 2022-10-29 09:55:18, ----- (0%)

def match(word,pattern,include_chars,exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != '?' and word[i] != pattern[i] :
            return False
        elif word[i] != '?' and word[i] == pattern[i] :
            return True
    k1 = 0
    ind = []
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            ind.append(i)
    ec = [e for e in exclude_chars]
    for i in range(len(ind)) :
        for j in range(len(word)) :
            if word[j][ind[i]] in ec :
                return False
    ic = [e for e in include_chars]
    for i in range(len(ind)) :
        for j in range(len(word)) :
            if word[i][ind[i]] not in ic :
                return False
            else :
                ic.remove[word[i][ind[i]]]
        

# 1662568, 2022-10-29 10:02:09, ----- (0%)

def match(word,pattern,include_chars,exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and pattern[i] != word[i] :
            return False
    ind = []
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            ind.append(i)
    ec = [e for e in exclude_chars]
    for i in range(len(ind)) :
        for j in range(len(word)) :
            if word[j][ind[i]] in ec :
                return False
            
    ic = [e for e in include_chars]
    for i in range(len(ind)) :
        for j in range(len(word)) :
            if word[i][ind[i]] not in ic :
                return False
            else :
                ic.remove[word[i][ind[i]]]
    return True
        
# 1662582, 2022-10-29 10:02:33, xxxxx (0%)

def match(word,pattern,include_chars,exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and pattern[i] != word[i] :
            return False
    ind = []
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            ind.append(i)
    ec = [e for e in exclude_chars]
    for i in range(len(ind)) :
        for j in range(len(word)) :
            if word[j][ind[i]] in ec :
                return False
            
    ic = [e for e in include_chars]
    for i in range(len(ind)) :
        for j in range(len(word)) :
            if word[i][ind[i]] not in ic :
                return False
            else :
                ic.remove[word[i][ind[i]]]
    return True

exec(input())
        

# 1662896, 2022-10-29 10:12:00, ----- (0%)

def match(word,pattern,include_chars,exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and pattern[i] != word[i] :
            return False
    ind = []
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            ind.append(i)
    for i in range(len(ind)) :
        if word[ind[i]] in exclude_chars :
            return False            
    ic = [e for e in include_chars]
    for i in range(len(ind)) :
        if word[ind[i]] not in ic :
            return False
        else :
            ic.remove(word[ind[i]])
    return True
    
exec(input())

# 1662925, 2022-10-29 10:12:44, ----- (0%)

def match(word,pattern,include_chars,exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and pattern[i] != word[i] :
            return False
    ind = []
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            ind.append(i)
    for i in range(len(ind)) :
        if word[ind[i]] in exclude_chars :
            return False            
    ic = [e for e in include_chars]
    for i in range(len(ind)) :
        if word[ind[i]] not in ic :
            return False
        else :
            ic.remove(word[ind[i]])
    return True
    
exec(input()) # DON'T remove this line
# 1663087, 2022-10-29 10:16:27, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and pattern[i] != word[i] :
            return False
    ind = []
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            ind.append(i)
    for i in range(len(ind)) :
        if word[ind[i]] in exclude_chars :
            return False            
    ic = [e for e in include_chars]
    if len(ic) == 0 : return True
    for i in range(len(ind)) :
        if len(ind) <= len(ic) :
            if word[ind[i]] not in ic :
                return False
            else :
                ic.remove(word[ind[i]])
        else :
            if word[ind[i]] not in ic :
                return False
    return True
    
exec(input()) # DON'T remove this line
# 1664032, 2022-10-29 10:35:38, P--P- (40%)

def match(word,pattern,include_chars,exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and pattern[i] != word[i] :
            return False
    ind = []
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            ind.append(i)
    for i in range(len(ind)) :
        if word[ind[i]] in exclude_chars :
            return False            
    ic = [e for e in include_chars]
    if len(ic) == 0 : return True
    w_ind = []
    for i in range(len(ind)) :
        w_ind.append(word[ind[i]])
    for i in range(len(ic)) :
        if len(ind) <= len(ic) :
            if ic[i] not in w_ind :
                return False
    return True
    
exec(input()) # DON'T remove this line

6530199921
# 1661906, 2022-10-29 09:40:41, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if not 'A' <= word <= 'Z' :
        return False
    if not len(word) == len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
    return True

exec(input()) # DON'T remove this line
# 1662517, 2022-10-29 10:00:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if not 'A' <= word <= 'Z' :
        return False
    if not len(word) == len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
    k = 0
    while True :
        k2 = pattern.find('?', k)
        if k2 == -1 : break
        if word[k2] in exclude_chars :
            return False
        if not word[k2] in include_chars :
            return False
        k = k2+1 
    return True

exec(input()) # DON'T remove this line
# 1662521, 2022-10-29 10:00:32, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if not 'A' <= word <= 'Z' :
        return False
    if not len(word) == len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
    return True

exec(input()) # DON'T remove this line
# 1662751, 2022-10-29 10:07:50, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):

    if not 'A' <= word <= 'Z' :
        return False
    if not len(word) == len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
    k = 0
    while True :
        k2 = pattern.find('?', k)
        if k2 == -1 : break
        if word[k2] in exclude_chars :
            return False
        if len(include_chars) != 0 and ( word[k2] not in include_chars) :
            return False
        k = k2+1 
    return True

exec(input()) # DON'T remove this line
# 1663014, 2022-10-29 10:14:57, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if not 'A' <= word <= 'Z' :
        return False
    if not len(word) == len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
    k = 0
    while True :
        k2 = pattern.find('?', k)
        if k2 == -1 : break
        if word[k2] in exclude_chars :
            return False
        if len(include_chars) != 0 and ( word[k2] not in include_chars) :
            return False
        k = k2+1
    return True

exec(input()) # DON'T remove this line
# 1663541, 2022-10-29 10:26:43, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if not 'A' <= word <= 'Z' :
        return False
    if not len(word) == len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
    k = 0
    aa = ''
    while True :
        k2 = pattern.find('?', k)
        if k2 == -1 : break
        if word[k2] in exclude_chars :
            return False
        aa += word[k2]
        if len(include_chars) != 0 and ( include_chars not in aa) :
            return False
        k = k2+1
    return True

exec(input()) # DON'T remove this line
# 1664337, 2022-10-29 10:39:17, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if not 'A' <= word <= 'Z' :
        return False
    elif not len(word) == len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] != '?' and word[i] != pattern[i] :
            return False
    k = 0
    aa = ''
    while True :
        k2 = pattern.find('?', k)
        if k2 == -1 : break
        if word[k2] in exclude_chars :
            return False
        aa += word[k2]
        if len(include_chars) != 0 and ( include_chars not in aa) :
            return False
        k = k2+1
    return True

exec(input()) # DON'T remove this line

6531348221
# 1661835, 2022-10-29 09:38:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return print("False")
    else:
        for i in range(len(word)):
             if pattern[i] != '?' and pattern[i] != word[i]:
                return print("False")
             if pattern[i] == '?':
                for j in exclude_chars:
                    stock = []
                    stock.append(j)
                    if word[i] in stock:
                        return False
                for k in range(len(include_chars)):
                    check = []
                    check.append(include_chars[k])
                    if word[i] not in check:
                        print("False")
                    else:
                        x = check.index(word[i])
                        check.pop(x)   
        return print("True")
exec(input()) # DON'T remove this line
# 1662285, 2022-10-29 09:52:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    stock = []
    for j in exclude_chars:
        stock.append(j)
    check = []
    for k in include_chars:
        check.append(k)
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
             if pattern[i] != '?' and pattern[i] != word[i]:
                return False
             if pattern[i] == '?':
                if word[i] in stock:
                    return False
                if word[i] not in check:
                    return False
        return True
exec(input()) # DON'T remove this line
# 1662300, 2022-10-29 09:53:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    stock = []
    for j in exclude_chars:
        stock.append(j)
    check = []
    for k in include_chars:
        check.append(k)
    if len(word) != len(pattern):
        return print("False")
    else:
        for i in range(len(word)):
             if pattern[i] != '?' and pattern[i] != word[i]:
                return print("False")
             if pattern[i] == '?':
                if word[i] in stock:
                    return print("False")
                if word[i] not in check:
                    return print("False") 
        return print("True")
exec(input()) # DON'T remove this line
# 1662395, 2022-10-29 09:56:53, ----- (0%)

# def match(word, pattern, include_chars, exclude_chars):
#     stock = []
#     for j in exclude_chars:
#         stock.append(j)
#     check = []
#     for k in include_chars:
#         check.append(k)
#     if len(word) != len(pattern):
#         return print("False")
#     else:
#         for i in range(len(word)):
#              if pattern[i] != '?' and pattern[i] != word[i]:
#                 return print("False")
#              if pattern[i] == '?':
#                 if word[i] in stock:
#                     return print("False")
#                 if word[i] not in check:
#                     return print("False") 
#         return print("True")
# exec(input()) # DON'T remove this line

def match(word, pattern, include_chars, exclude_chars):
    stock = []
    check = []
    if len(word) != len(pattern):
        return print("False")
    else:
        for i in range(len(word)):
             if pattern[i] != '?' and pattern[i] != word[i]:
                return print("False")
             if pattern[i] == '?':
                for j in exclude_chars:
                    stock.append(j)
                    if word[i] in stock:
                        return False
                for k in range(len(include_chars)):
                    check.append(include_chars[k])
                    if word[i] not in check and len(check) != 0:
                        return print("False")
                    else:
                        x = check.index(word[i])
                        check.pop(x) 
                        if len(check) == 0:
                            break
        return print("True")
exec(input()) # DON'T remove this line
# 1662421, 2022-10-29 09:57:37, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    stock = []
    check = []
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
             if pattern[i] != '?' and pattern[i] != word[i]:
                return False
             if pattern[i] == '?':
                for j in exclude_chars:
                    stock.append(j)
                    if word[i] in stock:
                        return False
                for k in range(len(include_chars)):
                    check.append(include_chars[k])
                    if word[i] not in check and len(check) != 0:
                        return False
                    else:
                        x = check.index(word[i])
                        check.pop(x) 
                        if len(check) == 0:
                            break
        return True
exec(input()) # DON'T remove this line
# 1663326, 2022-10-29 10:22:38, xxPxx (20%)

def match(word, pattern, include_chars, exclude_chars):
    stock = []
    for j in exclude_chars:
        stock.append(j)
    check = []
    for k in range(len(include_chars)):
        check.append(include_chars[k])
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
             if pattern[i] != '?' and pattern[i] != word[i]:
                return False
        for j in range(len(word)):
             if pattern[j] == '?':
                if word[j] in stock:
                    return False
        for k in range(len(word)):
            if pattern[k] == '?':
                if word[k] not in check and len(check) != 0:
                    return False
                else:
                    x = check.index(word[k])
                    check.pop(x) 
                    if len(check) == 0:
                        break
        return True
exec(input()) # DON'T remove this line
# 1663337, 2022-10-29 10:22:45, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    stock = []
    check = []
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
             if pattern[i] != '?' and pattern[i] != word[i]:
                return False
             if pattern[i] == '?':
                for j in exclude_chars:
                    stock.append(j)
                    if word[i] in stock:
                        return False
                for k in range(len(include_chars)):
                    check.append(include_chars[k])
                    if word[i] not in check and len(check) != 0:
                        return False
                    else:
                        x = check.index(word[i])
                        check.pop(x) 
                        if len(check) == 0:
                            break
        return True
exec(input()) # DON'T remove this line

6530201421
# 1662121, 2022-10-29 09:48:06, xx-xx (0%)

def match(word, pattern, include_chars, exclude_chars):
    Checker=True
    if len(word)!=len(pattern):
        Checker= False
    #Checker 2
    for i in range(len(word)):
        if pattern[i]!="?" and word[i]!=pattern[i]:
         Checker= False
    #Checker 3
    for i in range(len(word)):
        if word[i] in exclude_chars:
            Checker= False
    #Checker 4
    h=0
    point=word.find(include_chars[h])
    while point!=-1:
        if point == len(word):
            break
        h+=1
        if h==len(include_chars):
            break
        point=word.find(include_chars[h],point+1)
    if point==-1:
        Checker= False
    print(Checker)
exec(input()) # DON'T remove this line



# 1662185, 2022-10-29 09:50:04, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    Checker=True
    if len(word)!=len(pattern):
        Checker= False
    #Checker 2
    for i in range(len(word)):
        if pattern[i]!="?" and word[i]!=pattern[i]:
         Checker= False
    #Checker 3
    for i in range(len(word)):
        if word[i] in exclude_chars:
            Checker= False
    #Checker 4
    h=0
    if len(include_chars)!=0:
        point=word.find(include_chars[h])
        while point!=-1:
            if point == len(word):
                break
            h+=1
            if h==len(include_chars):
                break
            point=word.find(include_chars[h],point+1)
        if point==-1:
            Checker= False
    print(Checker)
exec(input()) # DON'T remove this line



# 1662227, 2022-10-29 09:51:12, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    Checker=True
    if len(word)!=len(pattern):
        Checker= False
    #Checker 2
    for i in range(len(word)):
        if pattern[i]!="?" and word[i]!=pattern[i]:
         Checker= False
    #Checker 3
    for i in range(len(word)):
        if word[i] in exclude_chars:
            Checker= False
    #Checker 4
    h=0
    if len(include_chars)!=0:
        point=word.find(include_chars[h])
        while point!=-1:
            if point == len(word):
                break
            h+=1
            if h==len(include_chars):
                break
            point=word.find(include_chars[h],point+1)
        if point==-1:
            Checker= False
    return Checker
exec(input()) # DON'T remove this line



# 1663183, 2022-10-29 10:19:09, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    Checker=True
    if len(word)!=len(pattern):
        Checker= False
    #Checker 2
    for i in range(len(word)):
        if pattern[i]!="?" and word[i]!=pattern[i]:
         Checker= False
    #Checker 3
    Question=[]
    for i in range(len(word)):
        if pattern[i]=="?":
            Question.append(word[i])
    for i in Question:
        if i in exclude_chars:
            Checker=False
    #เช็คว่าตัวพวก
    #Checker 4
    h=0
    if len(include_chars)!=0:
        point=word.find(include_chars[h])
        while point!=-1:
            if point == len(word):
                break
            h+=1
            if h==len(include_chars):
                break
            point=word.find(include_chars[h],point+1)
            if include_chars[h]!=include_chars[h-1]:
                point=0
        if point==-1:
            Checker= False
    return Checker
exec(input()) # DON'T remove this line

# 1664195, 2022-10-29 10:37:53, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    Checker=True
    if len(word)!=len(pattern):
        Checker= False
    if len(word)==len(pattern):
        #Checker 2
        for i in range(len(word)):
            if pattern[i]!="?" and word[i]!=pattern[i]:
             Checker= False
        #Checker 3
        Question=[]
        for i in range(len(word)):
            if pattern[i]=="?":
                Question.append(word[i])
        for i in Question:
            if i in exclude_chars:
                Checker=False
        #เช็คว่าตัวพวก
        #Checker 4
        h=0
        if len(include_chars)!=0:
            point=word.find(include_chars[h])
            while point!=-1 or h!=len(include_chars):
                h+=1
                if h==len(include_chars):
                    break
                point=word.find(include_chars[h])
                if point==-1:
                    break
                if include_chars[h]!=include_chars[h-1]:
                    point=0
            if point==-1:
                Checker= False
    return Checker
exec(input()) # DON'T remove this line



# 1664554, 2022-10-29 10:40:59, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    Checker=True
    if len(word)!=len(pattern):
        Checker= False
    if len(word)==len(pattern):
        #Checker 2
        for i in range(len(word)):
            if pattern[i]!="?" and word[i]!=pattern[i]:
             Checker= False
        #Checker 3
        Question=[]
        for i in range(len(word)):
            if pattern[i]=="?":
                Question.append(word[i])
        for i in Question:
            if i in exclude_chars:
                Checker=False
        #เช็คว่าตัวพวก
        #Checker 4
        h=0
        if len(include_chars)!=0:
            point=word.find(include_chars[h])
            while point!=-1 or h!=len(include_chars):
                h+=1
                if h==len(include_chars):
                    break
                point=word.find(include_chars[h])
                if point==-1:
                    break
                if include_chars[h]!=include_chars[h-1]:
                    point=0
            if point==-1:
                Checker= False
    return Checker
exec(input()) # DON'T remove this line







6531808621
# 1663539, 2022-10-29 10:26:41, P--P- (40%)

def found(s,x):
    lst = []
    for i in range(len(s)):
        if s.find(x,i,i+1) != -1:
            lst.append(s.find(x,i,i+1))
    return lst
def match(word, pattern, include_chars, exclude_chars):
    k = found(pattern,'?')
    #print(k)
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        #print(word[i])
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in k:
        if word[e] in exclude_chars:
            return False
    for e in k:
        if include_chars == '':
            return True         
        include_chars = include_chars.replace('',' ')
        include_chars = include_chars.split(' ')      
        if word[e] in  include_chars:
             include_chars.remove(word[e])
        return False
    return True

     
exec(input()) # DON'T remove this line

# 1663599, 2022-10-29 10:27:49, PxxPx (40%)

def found(s,x):
    lst = []
    for i in range(len(s)):
        if s.find(x,i,i+1) != -1:
            lst.append(s.find(x,i,i+1))
    return lst
def match(word, pattern, include_chars, exclude_chars):
    k = found(pattern,'?')
    #print(k)
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        #print(word[i])
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in k:
        if word[e] in exclude_chars:
            return False
    for e in k:
        if include_chars == '':
            return True         
        include_chars = include_chars.replace('',' ')
        include_chars = include_chars.split(' ')      
        if word[e] in  include_chars:
             include_chars.remove(word[e])
        else:
          return False
        
    return True

     
exec(input()) # DON'T remove this line
# 1663746, 2022-10-29 10:30:44, ----- (0%)

def found(s,x):
    lst = []
    for i in range(len(s)):
        if s.find(x,i,i+1) != -1:
            lst.append(s.find(x,i,i+1))
    return lst
def match(word, pattern, include_chars, exclude_chars):
    k = found(pattern,'?')
    #print(k)
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        #print(word[i])
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in k:
        if word[e] in exclude_chars:
            return False
    include_chars = include_chars.replace('',' ')
    include_chars = include_chars.split(' ') 
    for e in k:
        if include_chars == '':
            return True         
        if word[e] in  include_chars:
             include_chars.remove(word[e])
        else:
          return False
        
    return True

     
exec(input()) # DON'T remove this line
# 1663805, 2022-10-29 10:31:53, compilation error (0%)

def found(s,x):
    lst = []
    for i in range(len(s)):
        if s.find(x,i,i+1) != -1:
            lst.append(s.find(x,i,i+1))
    return lst
def match(word, pattern, include_chars, exclude_chars):
    k = found(pattern,'?')
    #print(k)
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        #print(word[i])
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in k:
        if word[e] in exclude_chars:
            return False
    if include_chars == '':
            return True         
        include_chars = include_chars.replace('',' ')
        include_chars = include_chars.split(' ')
    for e in k:        
        if word[e] in  include_chars:
             include_chars.remove(word[e])
        else:
          return False
        
    return True

     
exec(input()) # DON'T remove this line
# 1663840, 2022-10-29 10:32:40, P--P- (40%)

def found(s,x):
    lst = []
    for i in range(len(s)):
        if s.find(x,i,i+1) != -1:
            lst.append(s.find(x,i,i+1))
    return lst
def match(word, pattern, include_chars, exclude_chars):
    k = found(pattern,'?')
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in k:
        if word[e] in exclude_chars:
            return False
    if include_chars == '':
            return True         
    include_chars = include_chars.replace('',' ')
    include_chars = include_chars.split(' ')
    for e in k:        
        if word[e] in  include_chars:
             include_chars.remove(word[e])
        else:
          return False
        
    return True

     
exec(input()) # DON'T remove this line
# 1664352, 2022-10-29 10:39:24, P--P- (40%)

def found(s,x):
    lst = []
    for i in range(len(s)):
        if s.find(x,i,i+1) != -1:
            lst.append(s.find(x,i,i+1))
    return lst
def match(word, pattern, include_chars, exclude_chars):
    k = found(pattern,'?')
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    for e in k:
        if word[e] in exclude_chars:
            return False
    if include_chars == '':
            return True         
    include_chars = include_chars.replace('',' ')
    include_chars = include_chars.split(' ')
    for e in k:        
        if word[e] in  include_chars:
             include_chars.remove(word[e])
        else:
          return False
        
    return True

exec(input()) # DON'T remove this line

6530048821
# 1662676, 2022-10-29 10:05:28, ----- (0%)


def isEqual(word,pattern):
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True

def isNotin(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    return True
def isIn(word,pattern,include_chars):
    for i in range(len(word)):
        if pattern[i] == '?' and not(word[i] in include_chars):
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        if isEqual(word,pattern) and isNotin(word,pattern,exclude_chars) and isIn(word,pattern,include_chars):
            return True
        else:
            return False
    else:
        return False

exec(input())

# 1662714, 2022-10-29 10:06:33, ----- (0%)


def isEqual(word,pattern):
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True

def isNotin(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    return True
def isIn(word,pattern,include_chars):
    for i in range(len(word)):
        if pattern[i] == '?' and not(word[i] in include_chars):
            return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        if isEqual(word,pattern) and isNotin(word,pattern,exclude_chars) and isIn(word,pattern,include_chars):
            return print(True)
        else:
            return print(False)
    else:
        return print(False)

exec(input())
# 1662985, 2022-10-29 10:14:18, ----- (0%)


def isEqual(word,pattern):
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True

def isNotin(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    return True
def isIn(word,pattern,include_chars):
    lst = 0
    for i in range(len(word)):
        if pattern[i] == '?' and not(word[i] in include_chars):
            lst +=0
        else:
            lst +=1
    if lst != 0:
        return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        if isEqual(word,pattern) and isNotin(word,pattern,exclude_chars) and isIn(word,pattern,include_chars):
            return print(True)
        else:
            return print(False)
    else:
        return print(False)
exec(input())

# 1663008, 2022-10-29 10:14:44, ----- (0%)


def isEqual(word,pattern):
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True

def isNotin(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    return True
def isIn(word,pattern,include_chars):
    lst = 0
    for i in range(len(word)):
        if pattern[i] == '?' and not(word[i] in include_chars):
            lst +=0
        else:
            lst +=1
    if lst != 0:
        return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        if isEqual(word,pattern) and isNotin(word,pattern,exclude_chars) and isIn(word,pattern,include_chars):
            return True
        else:
            return False
    else:
        return False

exec(input())

# 1663585, 2022-10-29 10:27:31, P--P- (40%)


def isEqual(word,pattern):
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True

def isNotin(word,pattern,exclude_chars):
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] in exclude_chars:
            return False
    return True
def isIn(word,pattern,include_chars):
    lst = 0
    if len(include_chars) == 0:
        return True
    for i in range(len(word)):
        if pattern[i] == '?' and not(word[i] in include_chars):
            lst +=1
        else:
            lst +=0
    if lst != 0:
        return False
    return True

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        if isEqual(word,pattern) and isNotin(word,pattern,exclude_chars) and isIn(word,pattern,include_chars):
            return True
        else:
            return False
    else:
        return False
exec(input())



6530056821
# 1663722, 2022-10-29 10:30:23, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    for i in range(len(word)):
        if word[i] != pattern[i] or pattern[i] != '?':
            return False
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
        if word[i] in include_chars:
            c+=1
    if c == 0:
        return False
exec(input())
# 1664039, 2022-10-29 10:35:42, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == '?':
            pass
        else:
            return False
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                
                return False
        if word[i] in include_chars:
            c+=1
    if c == 0:
        return False
    return True
exec(input())
# 1664625, 2022-10-29 10:41:43, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == '?':
            pass
        else:
            return False
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
        if word[i] in include_chars:
            c+=1
        if include_chars == '':
            c+=1
    if c == 0:
        return False
    return True
exec(input())
# 1664657, 2022-10-29 10:42:11, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word)!= len(pattern):
    return False
    c = 0
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == '?':
            pass
        else:
            return False
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
        if word[i] in include_chars:
            c+=1
        if include_chars == '':
            c+=1
    if c == 0:
        return False
    return True
exec(input())
# 1664658, 2022-10-29 10:48:59, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!= len(pattern):
      return False
    c = 0
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == '?':
            pass
        else:
            return False
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
        if word[i] in include_chars:
            c+=1
        if include_chars == '':
            c+=1
    if c == 0:
        return False
    return True
exec(input())

6531343021
# 1662630, 2022-10-29 10:04:06, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    q = []
    word1 = word
    for i in range(len(word)):
        if pattern[i] == '?':
            q.append(word[i])
        else:
            if word[i] != pattern[i]:
                return False
    for i in include_chars:
        if i not in word1:
            return False
        else:
            word1 = word1[:word1.find(i)] + word1[word1.find(i) + 1:]
    for i in exclude_chars:
        if i in q:
            return False
    return True

# 1662639, 2022-10-29 10:04:22, xP-Px (40%)

def match(word, pattern, include_chars, exclude_chars):
    q = []
    word1 = word
    for i in range(len(word)):
        if pattern[i] == '?':
            q.append(word[i])
        else:
            if word[i] != pattern[i]:
                return False
    for i in include_chars:
        if i not in word1:
            return False
        else:
            word1 = word1[:word1.find(i)] + word1[word1.find(i) + 1:]
    for i in exclude_chars:
        if i in q:
            return False
    return True
exec(input()) # DON'T remove this line

# 1662748, 2022-10-29 10:07:49, xP-Px (40%)

def match(word, pattern, include_chars, exclude_chars):
    q = []
    word1 = word
    for i in range(len(word)):
        if pattern[i] == '?':
            q.append(word[i])
        else:
            if word[i] != pattern[i]:
                return False
    for i in include_chars:
        if i not in word1:
            return False
        else:
            word1 = word1.replace(i, '', 1)
    for i in exclude_chars:
        if i in q:
            return False
    return True
exec(input()) # DON'T remove this line
# 1663180, 2022-10-29 10:19:06, xP-Px (40%)

def match(word, pattern, include_chars, exclude_chars):
    q = []
    word1 = word
    for i in range(len(word)):
        if pattern[i] == '?':
            q.append(word[i])
        else:
            if word[i] != pattern[i]:
                return False
    for i in include_chars:
        if i not in word1:
            return False
        else:
            word1 = word1.replace(i, '', 1)
    for i in exclude_chars:
        if i in q:
            return False
    return True
exec(input()) # DON'T remove this line
# 1663577, 2022-10-29 10:27:28, xP-Px (40%)

def match(word, pattern, include_chars, exclude_chars):
    q = []
    word1 = word
    for i in range(len(word)):
        if pattern[i] == '?':
            q.append(word[i])
        else:
            if word[i] != pattern[i]:
                return False
    for j in include_chars:
        if j not in word1:
            return False
        else:
            word1 = word1.replace(j, '', 1)
    for k in exclude_chars:
        if k in q:
            return False
    return True
exec(input()) # DON'T remove this line

6530028221
# 1662374, 2022-10-29 09:56:10, ----- (0%)

def match(w,p,inc,e) :
    a=[]
    d=''
    x=''
    if len(w)!=len(p) :
        return False
    for k in range(len(p)) :
        if p[k]=='?' :
            pass
        else :
            if w[k]!=p[k] :
                return False
    for i in range(len(p)) :
        if p[i]=='?' :
            if w[i] in e :
                return False
    for i in range(len(p)) :
        if p[i]=='?' :
            d+=w[i]
    for k in inc :
        if k not in x :
            x+=k
    for k in x :
        if inc.count(k)<d.count(k) :
            print(inc.count(k),d.count(k))
            return False
    print(x)
    print(d)
    return True




exec(input())
if match("MACMA", "M?C??", "C", "")   :
    print('a')
else :
    print('d')


# 1662399, 2022-10-29 09:57:04, P--P- (40%)

def match(w,p,inc,e) :
    a=[]
    d=''
    x=''
    if len(w)!=len(p) :
        return False
    for k in range(len(p)) :
        if p[k]=='?' :
            pass
        else :
            if w[k]!=p[k] :
                return False
    for i in range(len(p)) :
        if p[i]=='?' :
            if w[i] in e :
                return False
    for i in range(len(p)) :
        if p[i]=='?' :
            d+=w[i]
    for k in inc :
        if k not in x :
            x+=k
    for k in x :
        if inc.count(k)<d.count(k) :
            print(inc.count(k),d.count(k))
            return False

    return True




exec(input())



# 1664529, 2022-10-29 10:40:48, P--P- (40%)

def match(w,p,inc,e) :
    a=[]
    d=''
    x=''
    if len(w)!=len(p) :
        return False
    for k in range(len(p)) :
        if p[k]=='?' :
            pass
        else :
            if w[k]!=p[k] :
                return False
    for i in range(len(p)) :
        if p[i]=='?' :
            if w[i] in e :
                return False
    for i in range(len(p)) :
        if p[i]=='?' :
            d+=w[i]
    for k in inc :
        if k not in x :
            x+=k
    for k in x :
        if inc.count(k)>d.count(k) :
            print(inc.count(k),d.count(k))
            return False

    return True




exec(input())
# 1664628, 2022-10-29 10:41:46, P--P- (40%)

def match(w,p,inc,e) :
    a=[]
    d=''
    x=''
    if len(w)!=len(p) :
        return False
    for k in range(len(p)) :
        if p[k]=='?' :
            pass
        else :
            if w[k]!=p[k] :
                return False
    for i in range(len(p)) :
        if p[i]=='?' :
            if w[i] in e :
                return False
    for i in range(len(p)) :
        if p[i]=='?' :
            d+=w[i]
    for k in inc :
        if k not in x :
            x+=k
    for k in x :
        if inc.count(k)>d.count(k) :
            print(inc.count(k),d.count(k))
            return False


    return True




exec(input())




6530088921
# 1662999, 2022-10-29 10:14:36, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] not in exclude_chars :
            for k in include_chars:
                if k not in word: return False
        elif pattern[i] != '?' and word[i] != pattern[i]: return False
exec(input())  # DON'T remove this line
# 1663035, 2022-10-29 10:15:34, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] not in exclude_chars :
            for k in include_chars:
                if k not in word: return False
        elif pattern[i] != '?' and word[i] != pattern[i]: return False
    return True
exec(input())  # DON'T remove this line
# 1663099, 2022-10-29 10:16:49, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] == '?' and word[i] not in exclude_chars :
            for k in include_chars:
                if k not in word: return False
        if pattern[i] != '?' and word[i] != pattern[i]: return False
    return True
exec(input())  # DON'T remove this line
# 1663691, 2022-10-29 10:29:43, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in include_chars:
        if i not in word: return False
    for i in range(len(word)):
        if pattern[i] != '?':
            if word[i] == pattern[i]:
                return True
        elif pattern[i] == '?':
            if word[i] not in exclude_chars:
                return True
    return False
#x = [match("MACMA", "M?C??", "AAA", ""),match("MACMA", "M?C??", "MAX", ""),match("MACMA", "M?C??", "C", ""),match("MACMA", "M?C??", "", "MX"),match("MACMA", "M?C???", "", ""),match("MACMA", "M?C?", "", "")]
#for i in x:
    #print(i)
exec(input())  # DON'T remove this line

6530146621
# 1662217, 2022-10-29 09:50:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i].lower():
            return False   
    for e in range(len(pattern)):   
        if pattern[e] == '?':
            if word[e] in exclude_chars:
                return False
    for c in include_chars:
        x = c.find(word)
        if x == '-1':
            return False
        elif pattern[x] != '?':
            return False
    return True 
            
    
exec(input())
# 1663670, 2022-10-29 10:29:17, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    m = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False   
    for e in range(len(pattern)):   
        if pattern[e] == '?':
            m.append(e)
            if word[e] in exclude_chars:
                return False
    for c in include_chars:
        x = c.find(word)
        if x == '-1':
            return False
        elif pattern[x] != '?':
            return False
    return True 
            
    
exec(input())

# 1664450, 2022-10-29 10:40:11, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i].lower():
            return False   
    for e in range(len(pattern)):   
        if pattern[e] == '?':
            m.append(e)
            if word[e] in exclude_chars:
                return False
    for c in include_chars:
        x = c.find(word)
        if x == '-1':
            return False
        elif pattern[x] != '?':
            return False
    return True 
            
exec(input())
# 1664466, 2022-10-29 10:40:21, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    m = []
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False   
    for e in range(len(pattern)):   
        if pattern[e] == '?':
            m.append(e)
            if word[e] in exclude_chars:
                return False
    for c in include_chars:
        x = c.find(word)
        if x == '-1':
            return False
        elif pattern[x] != '?':
            return False
    return True 
            
exec(input())

6531311021
# 1662033, 2022-10-29 09:45:11, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    b=True
    for e in include_chars:
        if e not in word:
            b=False
            print(False)
    if b:
        if len(word)==len(pattern):
            for i in range(len(word)):
                if word[i]==pattern[i] or (pattern[i]=='?'and (word[i] not in exclude_chars)):
                    boo=True
                else:
                    boo=False
            if boo:
                print(True)
            else:
                print(False)
        else:
            print(False)

exec(input())
# 1662135, 2022-10-29 09:48:34, ----- (0%)

print(1)
# 1662141, 2022-10-29 09:48:49, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    b=True
    for e in include_chars:
        if e not in word:
            b=False
            print(False)
    if b:
        if len(word)==len(pattern):
            for i in range(len(word)):
                if word[i]==pattern[i] or (pattern[i]=='?'and (word[i] not in exclude_chars)):
                    boo=True
                else:
                    boo=False
            if boo:
                print(True)
            else:
                print(False)
        else:
            print(False)

exec(input())
# 1663611, 2022-10-29 10:28:02, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    b=True
    for e in include_chars:
        if e not in word:
            b=False
            return(False)
    if b:
        if len(word)==len(pattern):
            for i in range(len(word)):
                if word[i]==pattern[i] or (pattern[i]=='?'and (word[i] not in exclude_chars)):
                    boo=True
                else:
                    boo=False
            if boo:
                return(True)
            else:
                return(False)
        else:
            return(False)
exec(input())

6430450221
# 1662653, 2022-10-29 10:04:48, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    a=False
    if len(word)==len(pattern):
        a=True
    b=False
    if a==True:
        for i in range(len(word)):
            if pattern[i]!='?':
                if pattern[i]==word[i]:
                    b=True
                else:
                    b=False
                    break
            else:
                b=True
    if a==True:
        q=[]
        c=True
        for i in range(len(word)):
            if pattern[i]=='?':
                q.append(word[i])
        for e in q:
            if e in exclude_chars:
                c=False
                break
    if a== True:
        pass
    if a==True and b==True and c==True:
        return True
    else:
        return False
        
exec(input()) # DON'T remove this line
# 1663828, 2022-10-29 10:32:17, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a=False
    if len(word)==len(pattern):
        a=True
    b=False
    if a==True:
        for i in range(len(word)):
            if pattern[i]!='?':
                if pattern[i]==word[i]:
                    b=True
                else:
                    b=False
                    break
            else:
                b=True
    if a==True:
        q=[]
        c=True
        for i in range(len(word)):
            if pattern[i]=='?':
                q.append(word[i])
        for e in q:
            if e in exclude_chars:
                c=False
                break
    if a== True:
        q.sort()
        r=''
        for e in q:
            r+=e
        x=[]
        for i in include_chars:
            x.append(i)
        x.sort()
        r2=''
        for e in r2:
            r2+=e
        if q==r2:
            d=True
        else:
            d=False
    if a==True and b==True and c==True and d==True:
        return True
    else:
        return False
        
exec(input()) # DON'T remove this line
# 1663862, 2022-10-29 10:32:58, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    a=False
    if len(word)==len(pattern):
        a=True
    b=False
    if a==True:
        for i in range(len(word)):
            if pattern[i]!='?':
                if pattern[i]==word[i]:
                    b=True
                else:
                    b=False
                    break
            else:
                b=True
    if a==True:
        q=[]
        c=True
        for i in range(len(word)):
            if pattern[i]=='?':
                q.append(word[i])
        for e in q:
            if e in exclude_chars:
                c=False
                break
    if a==True and b==True and c==True:
        return True
    else:
        return False
        
exec(input()) # DON'T remove this line

6530019621
# 1661930, 2022-10-29 09:41:34, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
#match("MACMA", "M?C??", "MAA", "")
    NotInEx = []
    MustInIn = []
    if len(word) != len(pattern):
        return False
    
    for i in range(len(pattern)):
        if pattern[i] != '?':
            MustInIn.append(word[i])
            if pattern[i] != word[i]:
                return False
        else:
            NotInEx.append(word[i])
            
    for j in range(len(word)):
        if word[j] in exclude_chars:
            return False
    
    for k in range(len(include_chars)):
        if include_chars[k] not in MustInIn:
            return False
    return True

exec(input()) # DON'T remove this line


# 1661939, 2022-10-29 09:41:48, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
#match("MACMA", "M?C??", "MAA", "")
    NotInEx = []
    MustInIn = []
    if len(word) != len(pattern):
        return False
    
    for i in range(len(pattern)):
        if pattern[i] != '?':
            MustInIn.append(word[i])
            if pattern[i] != word[i]:
                return False
        else:
            NotInEx.append(word[i])
            
    for j in range(len(word)):
        if word[j] in exclude_chars:
            return False
    
    for k in range(len(include_chars)):
        if include_chars[k] not in MustInIn:
            return False
    return True

exec(input()) # DON'T remove this line
# 1662510, 2022-10-29 10:00:05, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
#match("MACMA", "M?C??", "MAA", "")
    NotInEx = []
    MustInIn = []
    Mami = ''
    if len(word) != len(pattern):
        return False
    
    for i in range(len(pattern)):
        if pattern[i] != '?':
            if pattern[i] != word[i]:
                return False
        else:
            NotInEx.append(word[i])
            MustInIn.append([word[i],i])
            Mami += word[i]
            
    for j in range(len(NotInEx)):
        if NotInEx[j] in exclude_chars:
            return False
    #AMA #MAA
    for k in range(len(include_chars)):
        if include_chars[k] not in Mami:
            return False
    
        if include_chars[k][0] == MustInIn[k][0]:
            if include_chars.index(include_chars[k][0]) == MustInIn[k][1]:
                return False
        
    return True

exec(input()) # DON'T remove this line

#print(match("MACMA", "M?C??", "MAA", ""))


6530055121
# 1662677, 2022-10-29 10:05:28, compilation error (0%)

def check0(word,pattern):
    if len(word) == len(pattern):
        return 1
    else return 0

def check(word,pattern):
    p2 = ""
    for i in range(len(pattern)):
        if pattern[i] == "?":
            p2 += word[i]
        else:
            p2 += pattern[i]
    if p2 == word:
        return 1
    else:
        return 0
def check2(word,pattern,exclude_chars):
    c = 0
    w2 = ""
    for i in range(len(pattern)):
        if pattern[i] == "?":
            w2 += word[i]
    for i in range(len(w2)):
        if w2[i] in exclude_chars:
            c += 1
        else:
            c +=0
    if c == "0":
        return 1
    else:
        return 0
def check3(include_chars,word,pattern):
    if len(include_chars) == 0:
        return 1
    else:
        w2 = ""
        for i in range(pattern):
            if pattern[i] == "?":
                w2 += word[i]
            else:
                w2 += ""
        c = 0
        for i in range(len(include_chars)):
            if include_chars[i] in w2:
                c += 0
            else:
                c += 1
        if c == 0:
            return 1
        else:
            return 0 
    
def match(word, pattern, include_chars, exclude_chars):
   c = check0(word,pattern) + check(word,pattern) + check2(word,pattern,exclude_chars) + check3(include_chars,word,pattern)
   if c == 4:
       return True
    else:
        return False
exec(input()) 
# 1662742, 2022-10-29 10:07:37, xxx-x (0%)

def check0(word,pattern):
    if len(word) == len(pattern):
        return 1
    else:
        return 0

def check(word,pattern):
    p2 = ""
    for i in range(len(pattern)):
        if pattern[i] == "?":
            p2 += word[i]
        else:
            p2 += pattern[i]
    if p2 == word:
        return 1
    else:
        return 0
def check2(word,pattern,exclude_chars):
    c = 0
    w2 = ""
    for i in range(len(pattern)):
        if pattern[i] == "?":
            w2 += word[i]
    for i in range(len(w2)):
        if w2[i] in exclude_chars:
            c += 1
        else:
            c +=0
    if c == "0":
        return 1
    else:
        return 0
def check3(include_chars,word,pattern):
    if len(include_chars) == 0:
        return 1
    else:
        w2 = ""
        for i in range(pattern):
            if pattern[i] == "?":
                w2 += word[i]
            else:
                w2 += ""
        c = 0
        for i in range(len(include_chars)):
            if include_chars[i] in w2:
                c += 0
            else:
                c += 1
        if c == 0:
            return 1
        else:
            return 0 
    
def match(word, pattern, include_chars, exclude_chars):
   c = check0(word,pattern) + check(word,pattern) + check2(word,pattern,exclude_chars) + check3(include_chars,word,pattern)
   if c == 4:
       return True
   else:
       return False
exec(input())
# 1663648, 2022-10-29 10:28:44, xP-Px (40%)

def check0(word,pattern):
    if len(word) == len(pattern):
        return 1
    else:
        return 0

def check(word,pattern):
    p2 = ""
    for i in range(len(pattern)):
        if pattern[i] == "?":
            p2 += word[i]
        else:
            p2 += pattern[i]
    if p2 == word:
        return 1
    else:
        return 0
def check2(word,pattern,exclude_chars):
    c = 0
    w2 = ""
    for i in range(len(pattern)):
        if pattern[i] == "?":
            w2 += word[i]
    for i in range(len(w2)):
        if w2[i] in exclude_chars:
            c += 1
        else:
            c += 0
    if c == 0:
        return 1
    else:
        return 0
    
            
def check3(include_chars,word,pattern):
    if len(include_chars) == 0:
        return 1
    else:
        w2 = ""
        for i in range(len(pattern)):
            if pattern[i] == "?":
                w2 += word[i]
            else:
                w2 += ""
        c = 0
        for i in range(len(include_chars)):
            if include_chars[i] in w2:
                c += 0
            else:
                c += 1
        if c == 0:
            return 1
        else:
            return 0 
    
def match(word, pattern, include_chars, exclude_chars):
   c = check0(word,pattern) + check(word,pattern) + check2(word,pattern,exclude_chars) + check3(include_chars,word,pattern)
   if c == 4:
       return True
   else:
       return False
exec(input())

6530115121
# 1662795, 2022-10-29 10:08:57, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    I=[]
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and word[i] != pattern[i]:
            return False
        if pattern[i] =="?":
            I.append(i)
        if exclude_chars != "":
            for i in I:
                if word[i] in exclude_chars:
                    return False
    return True


exec(input()) # DON'T remove this line


# 1663393, 2022-10-29 10:23:50, PxxP- (40%)

def match(word, pattern, include_chars, exclude_chars):
    I=[]
    j=[]
    x=[]
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and word[i] != pattern[i]:
            return False
        if pattern[i] =="?":
            I.append(i)
        if exclude_chars != "":
            for i in I:
                if word[i] in exclude_chars:
                    return False
        if include_chars != "":
            for i in I:
                j.append(word[i])
            j.sort()
            for e in include_chars:
                x.append(e)
            x.sort()
            if len(j) < len(x):
                return False
            for s in range(len(j)):
                if j[s] != x[s]:
                    return False
    return True
exec(input()) # DON'T remove this line


# 1663481, 2022-10-29 10:25:35, PxxP- (40%)

def match(word, pattern, include_chars, exclude_chars):
    I=[]
    j=[]
    x=[]
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!="?" and word[i] != pattern[i]:
            return False
        if pattern[i] =="?":
            I.append(i)
        if exclude_chars != "":
            for i in I:
                if word[i] in exclude_chars:
                    return False
        if include_chars != "":
            for i in I:
                j.append(word[i])
            j.sort()
            for e in include_chars:
                x.append(e)
            x.sort()
            if len(j) < len(x):
                return False
            for i in range(len(j)):
                if j[i] not in x[i]:
                    return False
    return True
exec(input()) # DON'T remove this line



6530172921
# 1664116, 2022-10-29 10:36:52, P--P- (40%)

def  match(word, pattern, include_chars, exclude_chars):
    c = 0
    ref = len(include_chars)
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif len(include_chars) == 0 and len(exclude_chars) == 0:
            return True
        must_have = []
        for alpha in include_chars:
            must_have.append(alpha)
        if pattern[i] == "?" and word[i] in must_have:
            must_have.remove(word[i]) 
            c +=1
            if c >= ref:
                return True
            else:
                return False
    if ref == 0:
        return True
    else:
        return False
exec(input())
# 1664239, 2022-10-29 10:38:22, P--P- (40%)

def  match(word, pattern, include_chars, exclude_chars):
    c = 0
    ref = len(include_chars)
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif len(include_chars) == 0 and len(exclude_chars) == 0:
            return True
        must_have = []
        for alpha in include_chars:
            must_have.append(alpha)
        if pattern[i] == "?" and word[i] in must_have:
            must_have.remove(word[i]) 
            c +=1
            if c >= ref:
                return True
            else:
                return False
    if ref == 0:
        return True
    return False
exec(input())
# 1664246, 2022-10-29 10:38:28, P--P- (40%)

def  match(word, pattern, include_chars, exclude_chars):
    c = 0
    ref = len(include_chars)
    if len(word) != len(pattern):
        return False
    for i in range(len(pattern)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        elif pattern[i] == "?" and word[i] in exclude_chars:
            return False
        elif len(include_chars) == 0 and len(exclude_chars) == 0:
            return True
        must_have = []
        for alpha in include_chars:
            must_have.append(alpha)
        if pattern[i] == "?" and word[i] in must_have:
            must_have.remove(word[i]) 
            c +=1
            if c >= ref:
                return True
            else:
                return False
    if ref == 0:
        return True
    return False
exec(input())

6231417621
# 1662211, 2022-10-29 09:50:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    excl=list(exclude_chars)
    incl=list(include_chars)
    for i in range(len(word)):
        if pattern[i] !='?' and word[i] != pattern[i]:
            return False
        elif pattern[i] =='?'and i in excl:
            return False
        elif pattern[i] =='?'and i not in incl:
            return False
    return True
exec(input())
# 1662572, 2022-10-29 10:02:16, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    excl=list(exclude_chars)
    incl=list(include_chars)
    for i in range(len(word)):
        if pattern[i] !='?' and word[i] != pattern[i]:
            return False
        elif pattern[i] =='?'and word[i] in excl and len(excl) !=0:
            return False
        elif pattern[i] =='?'and word[i] not in incl and len(incl) !=0:
            return False
    return True
exec(input())

6430206521
# 1662923, 2022-10-29 10:12:43, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] != '?':
                return False
            elif word[i] in exclude_chars:
                return False
# 1663006, 2022-10-29 10:14:43, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i]:
            if pattern[i] != '?':
                return False
            elif word[i] in exclude_chars:
                return False
            elif word[i] in include_chars:
                return False
    return True
        
            
            
    
    
    
    
exec(input()) # DON'T remove this line

6531409921
# 1662447, 2022-10-29 09:58:18, PP--- (40%)

def  match(word, pattern, include_chars, exclude_chars):
    word = word.upper()
    pattern = pattern.upper()
    include_chars = include_chars.upper()
    exclude_chars =  exclude_chars.upper()
    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)):
        if pattern[i] != '?':
            if pattern[i] != word[i]:
                return False
    for i in range(len(word)):
        if word[i] == pattern[i] and word[i] == '?':
            if  word[i] in  exclude_chars:
                return False
    for i in range(len(include_chars)):
        if not include_chars[i] in word:
            return False
        else:
            if word[i] == '?':
                return False
                
    return True
exec(input())
            

# 1662577, 2022-10-29 10:02:23, PP--- (40%)

def  match(word, pattern, include_chars, exclude_chars):
    word = word.upper()
    pattern = pattern.upper()
    include_chars = include_chars.upper()
    exclude_chars =  exclude_chars.upper()
    if len(word) != len(pattern) :
        return False
    for i in range(len(pattern)):
        if pattern[i] != '?':
            if pattern[i] != word[i]:
                return False
    for i in range(len(word)):
        if word[i] == pattern[i] and pattern[i] == '?':
            if  word[i] in  exclude_chars:
                return False
    for i in range(len(include_chars)):
        if not include_chars[i] in word:
            return False
        else:
            if word[i] == '?':
                return False
                
    return True
exec(input())
            

6530138621
# 1663284, 2022-10-29 10:21:38, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    for i in range(len(pattern)):
        if pattern[i] != word[i]:
            if pattern[i] != '?':
                return False
    
    if exclude_chars == '':
        return True
    for z in exclude_chars:
        if z in word:
            return False
    return True
# 1663312, 2022-10-29 10:22:11, P--P- (40%)

def  match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
    for i in range(len(pattern)):
        if pattern[i] != word[i]:
            if pattern[i] != '?':
                return False
    
    if exclude_chars == '':
        return True
    for z in exclude_chars:
        if z in word:
            return False
    return True
    
exec(input())

6530082021
# 1662991, 2022-10-29 10:14:25, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    check = []
    include = []
    for e in include_chars:
        include.append(e)
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if pattern[i] == '?':
                    check.append(i)
                else:
                    pass
                for e in check:
                    if word[e] in exclude_chars:
                        return False

            else:
                return False
        return True
    else:
        return False
        
exec(input())

6530152321
# 1662283, 2022-10-29 09:52:54, P--P- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    for i in range(len(pattern)):
        if pattern[i] == '?':
            if word[i] in exclude_chars:
                return False
    for e in include_chars:
        k = e.find(word)
        if k == '-1':
            return False
        elif pattern[k] != '?':
            return False
    return True
exec(input())

6530154621
# 1662657, 2022-10-29 10:04:52, PP-xx (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i]!='?' and pattern[i]!=word[i]:
                return False
            else:
                index=0
                list_index=[]
                while index!=-1:
                    index=pattern.find('?',index)
                    if index!=-1:
                        list_index+=[index]
                        index+=1
                for k in list_index:
                    if word[k] in exclude_chars and exclude_chats!=' ':
                        return False
                for m in include_chars:
                    if m not in word:
                        return False
                return True
exec(input().strip())

6530180921
# 1663269, 2022-10-29 10:21:15, PP--- (40%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!= '?' and word[i]!=pattern[i]:
            return False
    p2 =[e for e in pattern if e != '?']
    single = [e for e in word]
    for k in p2:
        single.remove(k)
    inc = [e for e in include_chars]
    for k1 in inc:
        if k1 not in single and len(single)>=len(inc):
            return False
    return True
exec(input()) # DON'T remove this line

Max Score = 20


6530171221
# 1661933, 2022-10-29 09:41:37, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not '?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:
                ac += 1
            if ac == ap:
                m = True
        for k in include_chars:
            if k in word : m = true
            else : m = False
    return m
            
exec(input()) # DON'T remove this line
# 1661949, 2022-10-29 09:42:16, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not '?':ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:ac += 1
            if ac == ap: m = True
        for k in include_chars:
            if k in word : m = true
            else : m = False
    return m
            
exec(input())
# 1661960, 2022-10-29 09:42:42, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  m = False
  ap = 0
  for j in pattern:
      if j not '?':ap += 1
  if len(word) == len(pattern):
    ac = 0
    for i in range(len(word)):
      if (word[i] == pattern[i]) and word[i] not in exclude_chars:ac += 1
      if ac == ap: m = True
    for k in include_chars:
      if k in word : m = true
      else : m = False
  return m
exec(input())
# 1661985, 2022-10-29 09:43:25, Pxx-x (20%)

def match(word, pattern, include_chars, exclude_chars):
  m = False
  ap = 0
  for j in pattern:
      if j not in '?':ap += 1
  if len(word) == len(pattern):
    ac = 0
    for i in range(len(word)):
      if (word[i] == pattern[i]) and word[i] not in exclude_chars:ac += 1
      if ac == ap: m = True
    for k in include_chars:
      if k in word : m = true
      else : m = False
  return m
exec(input())
# 1662004, 2022-10-29 09:44:08, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
  m = False
  ap = 0
  for j in pattern:
      if j not in '?':ap += 1
  if len(word) == len(pattern):
    ac = 0
    for i in range(len(word)):
      if (word[i] == pattern[i]) and word[i] not in exclude_chars:ac += 1
      if ac == ap: m = True
    for k in include_chars:
      if k in word : m = True
      else : m = False
  return m
exec(input())
# 1662215, 2022-10-29 09:50:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:
                ac += 1
            if ac == ap:m = True
            if pattern[i] =='?' and word[i] not in exclude_chars:
                return False
        for k in range(len(include_chars)):
            if include_chars[k] in word :
                if include_chars[k] == '?':
                    m = True
            else :
                return False
    return m
# 1662289, 2022-10-29 09:53:12, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:
                ac += 1
            if ac == ap:m = True
            if pattern[i] =='?' and word[i] in exclude_chars:
                return False
        for k in range(len(include_chars)):
            if include_chars[k] in word :
                if include_chars[k] == '?':
                    m = True
            else :
                return False
    return m
# 1662301, 2022-10-29 09:53:35, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) :
                ac += 1
            if ac == ap:m = True
            if pattern[i] =='?' and word[i] in exclude_chars:
                return False
        for k in range(len(include_chars)):
            if include_chars[k] in word :
                if include_chars[k] == '?':
                    m = True
            else :
                return False
    return m
# 1662347, 2022-10-29 09:55:14, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:
                ac += 1
            if ac == ap:m = True
        for k in range(len(include_chars)):
            if include_chars[k] in word :
                if include_chars[k] == '?':
                    m = True
            else :
                m = False
    return m
# 1662360, 2022-10-29 09:55:34, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:
                ac += 1
            if ac == ap:m = True
    return m
# 1662381, 2022-10-29 09:56:32, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:ac += 1
            if ac == ap:
                m = True
        for k in include_chars:
            if k in word : m = True
            else : m = False
    return m
# 1664010, 2022-10-29 10:35:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:ac += 1
            if ac == ap:
                m = True
        for k in include_chars:
            if k in word :
                m = True
            else :
                m = False
    return m
# 1664549, 2022-10-29 10:40:57, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:ac += 1
            if ac == ap:
                m = True
        word.sort
        include_chars.sort()
        for k in lenge(len(include_chars)):
            if include_chars[k] == word[k]
                m = True
            else :
                return = False
    return m
# 1664571, 2022-10-29 10:41:10, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    m = False
    ap = 0
    for j in pattern:
        if j not in'?':
            ap += 1
    if len(word) == len(pattern):
        ac = 0
        for i in range(len(word)):
            if (word[i] == pattern[i]) and word[i] not in exclude_chars:ac += 1
            if ac == ap:
                m = True
        word.sort
        include_chars.sort()
        for k in lenge(len(include_chars)):
            if include_chars[k] == word[k]:
                m = True
            else :
                return = False
    return m

6530063121
# 1662269, 2022-10-29 09:52:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    re=True
    if len(word)!=len(pattern):
        re=False
    else:
        qm=""
        nqm=""
        for i in range(len(word)):
            if pattern[i]!="?" and pattern[i]!=word[i]:
                re=False
            elif pattern[i]=="?":
                qm+=word[i]
            elif pattern[i]==word[i]:
                nqm+=word[i]
        for e in qm:
            if e not in exclude_chars:
                re=False
                break
        for u in nqm:
            if u not in include_chars:
                re=False
                break
    return re
# 1662294, 2022-10-29 09:53:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    re=True
    if len(word)!=len(pattern):
        re=False
    else:
        qm=""
        nqm=""
        for i in range(len(word)):
            if pattern[i]!="?" and pattern[i]!=word[i]:
                re=False
            elif pattern[i]=="?":
                qm+=word[i]
            elif pattern[i]==word[i]:
                nqm+=word[i]
        for e in qm:
            if e not in exclude_chars:
                re=False
                break
        for u in nqm:
            if u not in include_chars:
                re=False
                break
    return re
exec(input())
# 1662341, 2022-10-29 09:54:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    re=True
    if len(word)!=len(pattern):
        re=False
    else:
        qm=""
        nqm=""
        for i in range(len(word)):
            if pattern[i]!="?" and pattern[i]!=word[i]:
                re=False
            elif pattern[i]=="?":
                qm+=word[i]
            elif pattern[i]==word[i]:
                nqm+=word[i]
        for e in qm:
            if e in exclude_chars:
                re=False
                break
        for u in nqm:
            if u not in include_chars:
                re=False
                break
    return re
        
exec(input())
# 1663574, 2022-10-29 10:27:24, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    if len(word)!=len(pattern):
        r= False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
                r= False
        else:
            if pattern[i]=="?":
                qm+=word[i]
            elif pattern[i]==word[i]:
                nqm+=word[i]
    for e in qm:
        if e  in exclude_chars:
            r = False
            break
    for u in nqm:
        if u not in include_chars:
            r= False
            break
    print(r)
        
exec(input())
# 1663675, 2022-10-29 10:29:22, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    if len(word)!=len(pattern):
        r= False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
                r= False
        else:
            if pattern[i]=="?":
                qm+=word[i]
            elif pattern[i]==word[i]:
                nqm+=word[i]
    for e in qm:
        if e  in exclude_chars:
            r = False
            break
    for u in nqm:
        if u not in include_chars:
            r= False
            break
    return(r)
        
exec(input())
# 1663700, 2022-10-29 10:29:52, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    for i in range(len(word)):
        if pattern[i]=="?":
            qm+=word[i]
        elif pattern[i]==word[i]:
            nqm+=word[i]
        
    if len(word)!=len(pattern):
        r= False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
                r= False
    for e in qm:
        if e  in exclude_chars:
            r = False
            break
    for u in nqm:
        if u not in include_chars:
            r= False
            break
    print(r)
        
exec(input())
# 1663777, 2022-10-29 10:31:14, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    for i in range(len(word)):
        if pattern[i]=="?":
            qm+=word[i]
        elif pattern[i]==word[i]:
            nqm+=word[i]
        
    if len(word)!=len(pattern):
        r= False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
                r= False
    for e in qm:
        if e  in exclude_chars:
            r = False
            break
    for u in nqm:
        if u not in include_chars:
            r= False
            break
    return(r)
        
exec(input())
# 1663826, 2022-10-29 10:32:15, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    for i in range(len(word)):
        if pattern[i]=="?":
            qm+=word[i]
        elif pattern[i]==word[i]:
            nqm+=word[i]
        
    if len(word)!=len(pattern):
        r= False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
                r= False
    return(r)
        
exec(input())
# 1663968, 2022-10-29 10:34:38, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    for i in range(len(word)):
        if pattern[i]=="?":
            qm+=word[i]
        elif pattern[i]==word[i]:
            nqm+=word[i]
        
    if len(word)!=len(pattern):
        return False
      else:
        return True
exec(input())
# 1663983, 2022-10-29 10:34:56, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
      else:
        return True
exec(input())
# 1664092, 2022-10-29 10:36:31, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    for i in range(len(word)):
        if pattern[i]=="?":
            qm+=word[i]
        elif pattern[i]==word[i]:
            nqm+=word[i]
        
    if len(word)!=len(pattern):
        r= False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
                r= False
    for e in qm:
        if e  in exclude_chars:
            r = False
            break
    return(r)
        
exec(input())
# 1664220, 2022-10-29 10:38:07, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    for i in range(len(word)):
        if pattern[i]=="?":
            qm+=word[i]
        elif pattern[i]==word[i]:
            nqm+=word[i]
        
    if len(word)!=len(pattern):
        r= False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
                r= False
    for e in qm:
        if e  in exclude_chars:
            r = False
            break
        else:
            for u in nqm:
                if u not in include_chars:
                    r= False
                    break
    return(r)
        
exec(input())
# 1664236, 2022-10-29 10:38:19, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    r=True
    qm=""
    nqm=""
    for i in range(len(word)):
        if pattern[i]=="?":
            qm+=word[i]
        elif pattern[i]==word[i]:
            nqm+=word[i]
        
    if len(word)!=len(pattern):
        r= False
    for i in range(len(word)):
        if pattern[i]!="?" and pattern[i]!=word[i]:
                r= False
    for e in qm:
        if e  in exclude_chars:
            r = False
            break
    return(r)
        
exec(input())


6530033321
# 1662721, 2022-10-29 10:06:47, xxxxx (0%)

fn1 = input()
fn2 = input()
f1 = open(fn1, "r")
f2 = open(fn2, "r")

l = []
for line1 in f1:
    x = line1.split()
    for i in x:
        l.append(i.lower())
line1 = f1.readline()


for line2 in f2:
    for e in l:
        k = line2.find(e)
        if k == -1:
            line2 = f2.readline()
        else:
            line2.replace(line2[k:len(e)+1], '<e>'+line2[k:len(e)+1]+'</>')
        print(line2)

    


# 1662898, 2022-10-29 10:12:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True

# 1662904, 2022-10-29 10:12:11, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True
# 1662918, 2022-10-29 10:12:41, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    return True
exec(input())
# 1664006, 2022-10-29 10:35:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    n = ''
    k = pattern.find('?')
    while k != -1:
        n += word[k]
        k = pattern.find('?', k+1)
    
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False

    for i in exclude_chars:
        if i in n:
            return False
        else:
            return True

# 1664045, 2022-10-29 10:35:48, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    n = ''
    k = pattern.find('?')
    while k != -1:
        n += word[k]
        k = pattern.find('?', k+1)
    
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False

    for i in exclude_chars:
        if i in n:
            return False
        else:
            return True
exec(input())
# 1664061, 2022-10-29 10:35:55, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    n = ''
    k = pattern.find('?')
    while k != -1:
        n += word[k]
        k = pattern.find('?', k+1)
    
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False

    for i in exclude_chars:
        if i in n:
            return False
        else:
            return True
exec(input())
# 1664119, 2022-10-29 10:36:56, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        return True

exec(input())
# 1664448, 2022-10-29 10:40:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
    n = ''
    k = pattern.find('?')
    while k != -1:
        n += word[k]
        k = pattern.find('?', k+1)
    
    for i in exclude_chars:
        if i in n:
            return False
        else:
            return True
exec(input())
# 1664485, 2022-10-29 10:40:32, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return False
        return True

exec(input())

6530185021
# 1662280, 2022-10-29 09:52:50, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        if word[i] == "?" and word[i] in exclude_chars:
            return False
    #for i in range(len(include_chars)):
        #if include_chars[i]
    return True

exec(input())
# 1662585, 2022-10-29 10:02:39, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif word[i] == "?" and word[i] in exclude_chars:
            return False
    #for i in range(len(include_chars)):
        #if include_chars[i]
    return True

exec(input())
# 1663273, 2022-10-29 10:21:22, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif if word[i] == "?" and word[i] in exclude_chars:
            return False
        else:
            return False
    return True

exec(input())
# 1663294, 2022-10-29 10:21:50, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif if word[i] == "?" and word[i] in exclude_chars:
            return False
    return True

exec(input())
# 1663328, 2022-10-29 10:22:39, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif word[i] == "?" and word[i] in exclude_chars:
            return False
    return True

exec(input())
# 1663563, 2022-10-29 10:27:06, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif word[i] == "?" and word[i] in exclude_chars:
            return False
        elif exclude_chars[i] not in word:
            return False
    return True

exec(input())
# 1663578, 2022-10-29 10:27:28, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif word[i] == "?" and word[i] in exclude_chars:
            return False
    return True

exec(input())
# 1663897, 2022-10-29 10:33:26, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif word[i] == "?" and word[i] in exclude_chars:
            return False
        elif word.count(include_chars[i]) != include_chars.count(include_chars[i]):
            return False
    return True

exec(input())
# 1663909, 2022-10-29 10:33:43, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif word[i] == "?" and word[i] in exclude_chars:
            return False
    return True

exec(input())
# 1664341, 2022-10-29 10:39:19, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != "?" and word[i] != pattern[i]:
            return False
        elif word[i] == "?" and word[i] in exclude_chars:
            return False
    return True

exec(input()) # DON'T remove this line

6330175621
# 1661708, 2022-10-29 09:33:00, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    



exec(input())
# 1662479, 2022-10-29 09:59:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):    
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            else:
                return True
# 1662497, 2022-10-29 09:59:35, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):    
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            else:
                return True
                
exec(input())
# 1662757, 2022-10-29 10:08:06, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):    
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
        for i in range(len(pattern)):
            if pattern[i] == '?':
                if word[i] in exclude_chars:
                    return False
                else:
                    return True
exec(input())
# 1663153, 2022-10-29 10:18:26, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):    
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
        for i in range(len(pattern)):
            if pattern[i] == '?':
                if word[i] in exclude_chars:
                    return False
                else:
                    return True

exec(input())
# 1663234, 2022-10-29 10:20:11, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):    
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
        for i in range(len(pattern)):
            if pattern[i] == '?':
                if word[i] in exclude_chars:
                    return False
                return True
exec(input())
# 1663472, 2022-10-29 10:25:28, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):    
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
        for i in range(len(pattern)):
            if pattern[i] == '?':
                if word[i] in exclude_chars:
                    return False
                if word[i] not in include_chars:
                    return False
                return True
                

exec(input())
# 1663478, 2022-10-29 10:25:31, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):    
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
        for i in range(len(pattern)):
            if pattern[i] == '?':
                if word[i] in exclude_chars:
                    return False
                if word[i] not in include_chars:
                    return False
                return True
                

exec(input())
# 1663632, 2022-10-29 10:28:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = True
    if len(word) != len(pattern):
        c = False
    elif len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                c = False
        for i in range(len(pattern)):
            if pattern[i] == '?':
                if word[i] in exclude_chars:
                    c = False
                if word[i] not in include_chars:
                    c = False
                    
    return c
                

exec(input())
# 1664104, 2022-10-29 10:36:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    elif len(word) == len(pattern):
        
        for i in range(len(word)):
            if word[i] != pattern[i] and pattern[i] != '?':
                return False
            
            
        for i in range(len(pattern)):
            if pattern[i] == '?':
                if word[i] in exclude_chars:
                    return  False
                if word[i] not in include_chars:
                    return False
    return True
                

exec(input())

6231110921
# 1661831, 2022-10-29 09:38:38, compilation error (0%)

def def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
        
exec(input()) # DON'T remove this line

# 1661842, 2022-10-29 09:39:00, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
        
exec(input()) # DON'T remove this line
# 1662499, 2022-10-29 09:59:40, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            elif word[i] == '?' :
                count=0
                if word[i] in list(exclude_chars):
                    return False
                else:
                    count+=1
                if count > len(include_chars):
                    return True
            else:
                return True
                

        
exec(input()) # DON'T remove this line

# 1663842, 2022-10-29 10:32:42, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            elif word[i] == '?' :
                count=0
                if word[i] in list(exclude_chars):
                    return False
                else:
                    count+=1
                if count < len(include_chars):
                    return False
            else:
                return True
                

        
exec(input()) # DON'T remove this line
# 1664141, 2022-10-29 10:37:10, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            elif word[i] == '?' :
                count=0
                if word[i] in list(exclude_chars):
                    return False
                else:
                    count+=1
                if count < len(include_chars):
                    return False
                else:
                    for j in range(len(include_chars)):
                        if include_chars[j] == words[i]:
                            return True
                    
            else:
                return True
                

        
exec(input()) # DON'T remove this line

# 1664343, 2022-10-29 10:39:21, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            elif word[i] == '?' :
                count=0
                if word[i] in list(exclude_chars):
                    return False
                else:
                    count+=1
                if count < len(include_chars):
                    return False
                else:
                    for j in range(len(include_chars)):
                        if include_chars[j] == words[i]:
                            return True
                    

                

        
exec(input()) # DON'T remove this line
# 1664392, 2022-10-29 10:39:45, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            elif word[i] == '?' :
                count=0
                if word[i] in list(exclude_chars):
                    return False
                else:
                    count+=1
                if count < len(include_chars):
                    return False
                else:
                    for j in range(len(include_chars)):
                        if include_chars[j] == words[i] and pattern[i]=='?':
                            return True
                    
            else:
                return True
                

        
exec(input()) # DON'T remove this line
# 1664606, 2022-10-29 10:41:31, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            elif word[i] == '?' :
                count=0
                if word[i] in list(exclude_chars):
                    return False
                else:
                    count+=1
                if count < len(include_chars):
                    return False
                else:
                    for j in range(len(include_chars)):
                        if include_chars[j] == words[i] and pattern[i]=='?':
                            return True
                    
            else:
                return False
                

        
exec(input()) # DON'T remove this line
# 1664620, 2022-10-29 10:41:41, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] != pattern[i]:
                return False
            elif word[i] == '?' :
                count=0
                if word[i] in list(exclude_chars):
                    return False
                else:
                    count+=1
                if count < len(include_chars):
                    return False
                else:
                    for j in range(len(include_chars)):
                        if include_chars[j] == words[i] and pattern[i]=='?':
                            return True
                    
            else:
                return True
                

        
exec(input()) # DON'T remove this line

6430328421
# 1663398, 2022-10-29 10:23:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return False
 for i in range (len(word)):
    if pattern[i] != '?' and word[i].lower() != pattern[i]:
        return False
 return True

exec(input()) # DON'T remove this line
# 1663506, 2022-10-29 10:26:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return 'False'
 for i in range (len(word)):
    if pattern[i] != '?' and word[i].lower() != pattern[i]:
        return 'False'
 return 'True'

exec(input()) # DON'T remove this line
# 1663550, 2022-10-29 10:26:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return 'False'
 for i in range (len(word)):
    if pattern[i] != '?' and word[i] != pattern[i]:
        return 'False'
 return 'True'

exec(input()) # DON'T remove this line


# 1664042, 2022-10-29 10:35:45, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return False
 for i in range (len(word)):
    if pattern[i] != '?' and word[i] != pattern[i]:
        return False
 return True

exec(input()) # DON'T remove this line
# 1664319, 2022-10-29 10:39:04, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return False
 for i in range (len(word)):
    if pattern[i] != '?' and word[i] != pattern[i]:
        return True
 return True

exec(input()) # DON'T remove this line
# 1664336, 2022-10-29 10:39:16, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return False
 for i in range (len(word)):
    if pattern[i] != '?' and word[i] != pattern[i]:
        return False
 return True

exec(input()) # DON'T remove this line
# 1664359, 2022-10-29 10:39:30, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return False
 for i in range (len(word)):
    if pattern[i] != '?' and word[i] != pattern[i]:
        return False
 return False

exec(input()) # DON'T remove this line
# 1664379, 2022-10-29 10:39:39, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return False
 for i in range (len(word)):
    if pattern[i] != '?' and word[i] != pattern[i]:
        return False
 return True

exec(input()) # DON'T remove this line
# 1664501, 2022-10-29 10:40:39, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
 if len(word) != len(pattern):
        return False
 for i in range (len(word)):
    if pattern[i] != '?' and word[i] != pattern[i]:
        return False
    else:
        return True
 return True

exec(input()) # DON'T remove this line

6431418421
# 1663127, 2022-10-29 10:17:46, ---P- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return'False'
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] !=pattern[i]:
            return 'False'
    k1=0
    while True:
        k2=pattern.find('?',k1)
        if k2 == -1:
            break
        for t in exclude_chars:
            if t == word[k2]:
                return 'False'
        k1=k2+1
    k10=0
    while True:
        k2=pattern.find('?',k10)
        if k2 == -1:
            break
        for t in include_chars:
            if t != word[k2]:
                return 'False'
        k10=k2+1
    return'True'
exec(input()) # DON'T remove this line
# 1663708, 2022-10-29 10:30:04, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return'False'
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] !=pattern[i]:
            return 'False'
    k1=0
    while True:
        k2=pattern.find('?',k1)
        if k2 == -1:
            break
        for t in exclude_chars:
            if t == word[k2]:
                return 'False'
        k1=k2+1
    k10=0
    q=[]
    qq=[]
    while True:
        k2=pattern.find('?',k10)
        if k2 == -1:
            break
        q.append(word[k2])
        k10=k2+1
    for u in include_chars:
        qq.append(u)
    q.sort()
    qq.sort()
    if q != qq:
        return 'False'
        k10=k2+1
    return'True'
exec(input()) # DON'T remove this line
# 1663718, 2022-10-29 10:30:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return'False'
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] !=pattern[i]:
            return 'False'
    k1=0
    while True:
        k2=pattern.find('?',k1)
        if k2 == -1:
            break
        for t in exclude_chars:
            if t == word[k2]:
                return 'False'
        k1=k2+1
    k10=0
    q=[]
    qq=[]
    while True:
        k2=pattern.find('?',k10)
        if k2 == -1:
            break
        q.append(word[k2])
        k10=k2+1
    for u in include_chars:
        qq.append(u)
    q.sort()
    qq.sort()
    if q != qq:
        return 'False'
        k10=k2+1
    return'True'
exec(input()) # DON'T remove this line
# 1663893, 2022-10-29 10:33:25, ---P- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return'False'
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] !=pattern[i]:
            return 'False'
    k1=0
    while True:
        k2=pattern.find('?',k1)
        if k2 == -1:
            break
        for t in exclude_chars:
            if t == word[k2]:
                return 'False'
        k1=k2+1
    k10=0
    q=[]
    qq=[]
    while True:
        k2=pattern.find('?',k10)
        if k2 == -1:
            break
        q.append(word[k2])
        k10=k2+1
    for u in include_chars:
        qq.append(u)
    q.sort()
    qq.sort()
    if qq in q:
        return 'True'
        k10=k2+1
    return'True'
exec(input()) # DON'T remove this line
# 1664121, 2022-10-29 10:36:56, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return'False'
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] !=pattern[i]:
            return 'False'
    k1=0
    while True:
        k2=pattern.find('?',k1)
        if k2 == -1:
            break
        for t in exclude_chars:
            if t == word[k2]:
                return 'False'
        k1=k2+1
    k10=0
    q=[]
    qq=[]
    while True:
        k2=pattern.find('?',k10)
        if k2 == -1:
            break
        q.append(word[k2])
        k10=k2+1
    for u in include_chars:
        qq.append(u)
    q.sort()
    qq.sort()
    if qq in q:
        return 'True'
    else:
        return 'False'
    return'True'
exec(input()) # DON'T remove this line
# 1664368, 2022-10-29 10:39:34, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return'False'
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] !=pattern[i]:
            return 'False'
    k1=0
    while True:
        k2=pattern.find('?',k1)
        if k2 == -1:
            break
        for t in exclude_chars:
            if t == word[k2]:
                return 'False'
        k1=k2+1
    k10=0
    q=[]
    qq=[]
    while True:
        k2=pattern.find('?',k10)
        if k2 == -1:
            break
        q.append(word[k2])
        k10=k2+1
    for u in include_chars:
        qq.append(u)
    q.sort()
    qq.sort()
    if qq[:len(q)] == q:
        return 'True'
    else:
        return 'False'
    return'True'
exec(input()) # DON'T remove this line

6530064821
# 1662663, 2022-10-29 10:05:01, P---- (20%)

def not_matching(w, p):
    if len(w) != len(p):
        return True
    for i in range(len(w)):
        if p[i] != "?" and w[i] != p[i]:
            return True
    return False
def second(word, pattern, exclude):
    for i in range(len(word)):
        j = pattern.find("?")
        if word[j] in exclude:
            return True
    return False
def allinclude(word, pattern, include):
    y = []
    z = list(include)
    for k in range(len(word)):
        t = pattern.find("?")
        y.append(word[t])  # y = ["M","A","C"]
    for e in z:   #["A","A","M","M"]
        if e not in y:
            return True
    return False
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    if not_matching(word, pattern):
        return False
    if second(word, pattern, exclude_chars):
        return False
    if allinclude(word, pattern, include_chars):
        return False
    return True
exec(input())
# 1662766, 2022-10-29 10:08:18, compilation error (0%)


 def not_matching(w, p):
    if len(w) != len(p):
        return True
    for i in range(len(w)):
        if p[i] != "?" and w[i] != p[i]:
            return True
    return False
def second(word, pattern, exclude):
    for i in range(len(word)):
        j = pattern.find("?")
        if word[j] in exclude:
            return True
    return False
def allinclude(word, pattern, include):
    y = []
    z = list(include)
    for k in range(len(word)):
        t = pattern.find("?")
        y.append(word[t]) 
    for e in y:   
        if e not in z:
            return True
    return False
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    if not_matching(word, pattern):
        return False
    if second(word, pattern, exclude_chars):
        return False
    if allinclude(word, pattern, include_chars):
        return False
    return True
exec(input())
# 1662771, 2022-10-29 10:08:28, ----- (0%)

def not_matching(w, p):
    if len(w) != len(p):
        return True
    for i in range(len(w)):
        if p[i] != "?" and w[i] != p[i]:
            return True
    return False
def second(word, pattern, exclude):
    for i in range(len(word)):
        j = pattern.find("?")
        if word[j] in exclude:
            return True
    return False
def allinclude(word, pattern, include):
    y = []
    z = list(include)
    for k in range(len(word)):
        t = pattern.find("?")
        y.append(word[t]) 
    for e in y:   
        if e not in z:
            return True
    return False
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    if not_matching(word, pattern):
        return False
    if second(word, pattern, exclude_chars):
        return False
    if allinclude(word, pattern, include_chars):
        return False
    return True
exec(input())
# 1662793, 2022-10-29 10:08:55, ----- (0%)

def not_matching(w, p):
    if len(w) != len(p):
        return True
    for i in range(len(w)):
        if p[i] != "?" and w[i] != p[i]:
            return True
    return False
def second(word, pattern, exclude):
    for i in range(len(word)):
        j = pattern.find("?")
        if word[j] in exclude:
            return True
    return False
def allinclude(word, pattern, include):
    y = []
    z = list(include)
    for k in range(len(word)):
        t = pattern.find("?")
        y.append(word[t]) 
    for e in y:   
        if e not in z:
            return True
    return False
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    if not_matching(word, pattern):
        return False
    if second(word, pattern, exclude_chars):
        return False
    if allinclude(word, pattern, include_chars):
        return False
    return True
exec(input())
# 1662832, 2022-10-29 10:10:03, P---- (20%)

def not_matching(w, p):
    if len(w) != len(p):
        return True
    for i in range(len(w)):
        if p[i] != "?" and w[i] != p[i]:
            return True
    return False
def second(word, pattern, exclude):
    for i in range(len(word)):
        j = pattern.find("?")
        if word[j] in exclude:
            return True
    return False
def allinclude(word, pattern, include):
    y = []
    z = list(include)
    for k in range(len(word)):
        t = pattern.find("?")
        y.append(word[t]) 
    for e in z:   
        if e not in y:
            return True
    return False
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    if not_matching(word, pattern):
        return False
    if second(word, pattern, exclude_chars):
        return False
    if allinclude(word, pattern, include_chars):
        return False
    return True
exec(input())
# 1663963, 2022-10-29 10:34:33, P---- (20%)

def not_matching(w, p):
    if len(w) != len(p):
        return True
    for i in range(len(w)):
        if p[i] != "?" and w[i] != p[i]:
            return True
    return False
def second(word, pattern, exclude):
    for i in range(len(word)):
        j = pattern.find("?")
        if word[j] in exclude:
            return True
    return False
def allinclude(word, pattern, include):
    y = []
    z = list(include)
    for k in range(len(word)):
        t = pattern.find("?")
        y.append(word[t]) 
    for e in z:   
        if e not in y:
            return True
    return False
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    elif not_matching(word, pattern):
        return False
    elif second(word, pattern, exclude_chars):
        return False
    elif allinclude(word, pattern, include_chars):
        return False
    return True
exec(input())

6530087221
# 1661973, 2022-10-29 09:43:07, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len (pattern) :
        for i in range(len(pattern)) :
            if pattern[i] != '?':
                if pattern[i] == word[i]:
                    pass
            
                else :
                    return(False)
                
    else :
        return(False)
exec(input()) # DON'T remove this line
# 1664126, 2022-10-29 10:37:03, -P--- (20%)

def match(word,pattern,include_chars,exclude_chars):
    k = 0
    j = []
    j += word
    for i in include_chars :
        if i in j :
            j.remove(i)
            k += 1
        else :
            return(bool(False))
    if k == len(include_chars) :
        if len(word) == len (pattern) :
            for i in range(len(pattern)) :
                if pattern[i] != '?':
                    if pattern[i] == word[i]:
                        return(bool(True))
                        pass
                    
                    else :
                        return(bool(False))
                else :
                    pass                
        else :
            return(bool(False))
    else :
        return(bool(False))
    
    for i in exclude_chars :
        if i not in pattern :
            pass
        elif i in pattern :
            return(bool(False))
exec(input()) # DON'T remove this line
# 1664525, 2022-10-29 10:40:47, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    k = 0
    j = []
    j += word
    for i in include_chars :
        if i in j :
            j.remove(i)
            k += 1
        else :
            return(bool(False))
    if k == len(include_chars) :
        if len(word) == len (pattern) :
            for i in range(len(pattern)) :
                if pattern[i] != '?':
                    if pattern[i] == word[i]:
                        return(bool(True))
                        pass
                    
                    else :
                        return(bool(False))
                else :
                    pass                
        else :
            return(bool(False))
    else :
        return(bool(False))
    
    for i in exclude_chars :
        if i not in word :
            pass
        elif i in word :
            return(bool(False))
print(match("MACMA", "M?C??", "", "MX"))
exec(input()) # DON'T remove this line

# 1664575, 2022-10-29 10:41:13, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    k = 0
    j = []
    j += word
    for i in include_chars :
        if i in j :
            j.remove(i)
            k += 1
        else :
            return(bool(False))
    if k == len(include_chars) :
        if len(word) == len (pattern) :
            for i in range(len(pattern)) :
                if pattern[i] != '?':
                    if pattern[i] == word[i]:
                        return(bool(True))
                        pass
                    
                    else :
                        return(bool(False))
                else :
                    pass                
        else :
            return(bool(False))
    else :
        return(bool(False))
    
    for i in exclude_chars :
        if i not in pattern :
            pass
        elif i in pattern :
            return(bool(False))
print(match("MACMA", "M?C??", "", "MX"))
exec(input()) # DON'T remove this line

# 1664611, 2022-10-29 10:41:34, -P--- (20%)

def match(word,pattern,include_chars,exclude_chars):
    k = 0
    j = []
    j += word
    for i in include_chars :
        if i in j :
            j.remove(i)
            k += 1
        else :
            return(bool(False))
    if k == len(include_chars) :
        if len(word) == len (pattern) :
            for i in range(len(pattern)) :
                if pattern[i] != '?':
                    if pattern[i] == word[i]:
                        return(bool(True))
                        pass
                    
                    else :
                        return(bool(False))
                else :
                    pass                
        else :
            return(bool(False))
    else :
        return(bool(False))
    
    for i in exclude_chars :
        if i not in pattern :
            pass
        elif i in pattern :
            return(bool(False))
exec(input()) # DON'T remove this line
# 1664631, 2022-10-29 10:41:48, compilation error (0%)

def match(word,pattern,include_chars,exclude_chars):
    k = 0
    j = []
    j += word
    for i in include_chars :
        if i in j :
            j.remove(i)
            k += 1
        else :
            return(bool(False))
    if k == len(include_chars) :
        if len(word) == len (pattern) :
            for i in range(len(pattern)) :
                if pattern[i] != '?':
                    if pattern[i] == word[i]:
                        return(bool(True))
                        pass
                    
                    else :
                        return(bool(False))
                else :
                    pass                
        else :
            return(bool(False))
    else :
        return(bool(False))
    
    for i in exclude_chars :
        if i not in word
        elif i in word :
            return(bool(False))
exec(input()) # DON'T remove this line

6530054521
# 1663796, 2022-10-29 10:31:35, ----- (0%)

print('False')
# 1664128, 2022-10-29 10:37:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return print(False)
    else:
        for e in pattern:
            for i in word:
                if e!='?':
                    if e==i:
                        return print(True)
                    else:
                        return print(False)
                else:
                    if e in exclude_chars:
                        return print(False)
                    else:
                        return print(True)
exec(input()) # DON'T remove this line

# 1664492, 2022-10-29 10:40:36, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return print(False)
    else:
        if include_chars=="" and exclude_chars!="":
            return print(False)
        if include_chars!="" and exclude_chars=="":
            return print(False)
        for e in pattern:
            for i in word:
                if e!='?':
                    if e==i:
                        return print(True)
                    else:
                        return print(False)
                else:
                    if e in exclude_chars:
                        return print(False)
                    else:
                        return print(True)
exec(input()) # DON'T remove this line

# 1664582, 2022-10-29 10:41:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return print(False)
    else:
        if include_chars=="" and exclude_chars!="":
            return print(False)
        if include_chars!="" and exclude_chars=="":
            return print(False)
        for e in pattern:
            for i in word:
                if e!='?':
                    if e==i:
                        return print(True)
                    else:
                        return print(False)
                else:
                    if e in exclude_chars:
                        return print(False)
                    else:
                        return print(True)
exec(input()) # DON'T remove this line

# 1664617, 2022-10-29 10:41:39, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return(False)
    else:
        if include_chars=="" and exclude_chars!="":
            return(False)
        if include_chars!="" and exclude_chars=="":
            return(False)
        for e in pattern:
            for i in word:
                if e!='?':
                    if e==i:
                        return(True)
                    else:
                        return(False)
                else:
                    if e in exclude_chars:
                        return(False)
                    else:
                        return(True)
exec(input()) # DON'T remove this line

6530157521
# 1662891, 2022-10-29 10:11:51, -x-Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    d = {}
    d1 = {}
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            pass
        else :
            if word[i] != pattern[i] :
                return False
            
    for c in (include_chars) :
        if c in d :
            d[c] += 1
        else :
            d[c] = 0
    for c in (word) :
        if c in d1 :
            d1[c] += 1
        else :
            d1[c] = 0
            
    for c in d :
        if c not in d :
            return False 
        elif int(d[c]) > int(d1[c]) :
            return False
    for c in exclude_chars :
        if c in word :
            return False
    return True
    
exec(input()) # DON'T remove this line
# 1662914, 2022-10-29 10:12:31, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    d = {}
    d1 = {}
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            pass
        else :
            if word[i] != pattern[i] :
                return False
            
    for c in (include_chars) :
        if c in d :
            d[c] += 1
        else :
            d[c] = 0
    for c in (word) :
        if c in d1 :
            d1[c] += 1
        else :
            d1[c] = 0
    for c in (include_chars) :
        if c not in d :
            return False 
        elif int(d[c]) > int(d1[c]) :
            return False
    for c in exclude_chars :
        if c in word :
            return False
    return True
    
# 1662919, 2022-10-29 10:12:41, -x-Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    d = {}
    d1 = {}
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            pass
        else :
            if word[i] != pattern[i] :
                return False
            
    for c in (include_chars) :
        if c in d :
            d[c] += 1
        else :
            d[c] = 0
    for c in (word) :
        if c in d1 :
            d1[c] += 1
        else :
            d1[c] = 0
            
    for c in d :
        if c not in d :
            return False 
        elif int(d[c]) > int(d1[c]) :
            return False
    for c in exclude_chars :
        if c in word :
            return False
    return True
    
exec(input()) # DON'T remove this line
# 1663378, 2022-10-29 10:23:34, -x-Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    d = {}
    d1 = {}
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            pass
        else :
            if word[i] != pattern[i] :
                return False
            
    for c in (include_chars) :
        if c in d :
            d[c] += 1
        else :
            d[c] = 0
    for c in (word) :
        if c in d1 :
            d1[c] += 1
        else :
            d1[c] = 0
            
    for c in d :
        if int(d[c]) > int(d1[c]) :
            return False
    for c in exclude_chars :
        if c in word :
            return False
    return True
    
exec(input()) # DON'T remove this line

6431507621
# 1661723, 2022-10-29 09:33:37, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    word = word.lower()
    pattern = pattern.lower()
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i]!= word[i]:
            return False
    return True
    
# 1661728, 2022-10-29 09:33:55, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    word = word.lower()
    pattern = pattern.lower()
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i]!= word[i]:
            return False
    return True
    
exec(input())
# 1661730, 2022-10-29 09:34:14, P---- (20%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    word = word.upper()
    pattern = pattern.upper()
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i]!= word[i]:
            return False
    return True
    
exec(input())

6431120321
# 1663142, 2022-10-29 10:18:08, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):

    
    x = ''
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != '?':
                x += pattern[i]
                if pattern[i] != word[i]:
                    return False
        if len(exclude_chars) > 0:
            for i in x:
                if i in exclude_chars:
                    return False
        return True
        
 
    else:
        return False
exec(input()) # DON'T remove this line
# 1663307, 2022-10-29 10:22:07, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):

    
    x = ''
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != '?':
                if pattern[i] != word[i]:
                    return False
            if pattern[i] == '?':
                x += pattern[i]
        
        if len(exclude_chars) > 0:
            for i in x:
                if i in exclude_chars:
                    return False
        return True
        
 
    else:
        return False
exec(input()) # DON'T remove this line
# 1663491, 2022-10-29 10:25:45, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):

    
    x = ''#เป็นตัวอักษรใน?
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] != '?':
                if pattern[i] != word[i]:
                    return False
            if pattern[i] == '?':
                x += pattern[i]
        
        if len(exclude_chars) > 0:
            for i in x:
                if i in exclude_chars:
                    return False
        
        if len(include_chars) > 0:
            for i in x:
                if i in include_chars:
                    return False
        return True
        

    else:
        return False
    
exec(input()) # DON'T remove this line

6430201321
# 1663525, 2022-10-29 10:26:29, -P--- (20%)

def match(word, pattern, include_chars, exclude_chars):
    word1 = list(word)
    pattern1 = list(pattern)
    include_char1 = list(include_chars)
    exclude_chars1 = list(exclude_chars)
    check = []
    
    
    key = 0
    if len(word1) == len(pattern1):
        for i in range(len(word1)):
            if word1[i] == pattern1[i] or pattern1[i] == '?':
                if pattern1[i] == '?':
                    if word1[i] not in exclude_chars1:
                        key = 1
                elif pattern1[i] != '?':
                    key = 1
                               
                
    if key == 1:
        for i in range(len(word1)):
            if pattern1[i] == '?':
                check.append(word1[i])
                
        n = len(include_char1)
        for i in range(len(include_char1)):
            if include_char1[i] in check:
                n -= 1
                
            
                
        if n == 0:
            return True
        else:
            return False
            
exec(input()) # DON'T remove this line

6432032021
# 1662811, 2022-10-29 10:09:20, -P--- (20%)

def  match(word, pattern, include_chars, exclude_chars):
    word = word.lower()
    pattern = pattern.lower()
    include_chars = include_chars.lower()
    exclude_chars = exclude_chars.lower()
    
    if len(word) == len(pattern):
        check = []
        wrong = []
        for i in range(len(pattern)):
            if pattern[i] != '?':
                check.append(i)
            else:
                wrong.append(i)
        h = 0
        for i in check:
            if word[i] == pattern[i]:
                h += 1
        if h == len(check):
            h1 = 0
            for i in wrong:
                if word[i] not in exclude_chars:
                    h1 += 1
            if h1 == len(wrong):
                h2 = 0
                for i in wrong:
                    if word[i] in include_chars:
                        h2 += 1
                if h2 == len(include_chars):
                    return True
                return False
                
exec(input())

6530121921
# 1662612, 2022-10-29 10:03:16, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and word[i] != pattern[i]:
            return False
    #for i in range(len(word)):
     #   if pattern[i] == '?' 
    
    
    
    return True
exec(input()) # DON'T remove this line

6530147221
# 1662594, 2022-10-29 10:02:56, x--Px (20%)

def match(word, pattern, include_chars, exclude_chars):
    
    A = True
    al = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    for i in word:
        if i in al:
            pass
        else:
            A = False
    B = True
    k = 0
    for i in pattern:
        if i in al:
            pass
        elif i == "?":
        
            k += 1
        else:
            B = False
    C = True
    for i in include_chars:
        if i in al:
            pass
        else:
            C = False
    if len(include_chars) <= k:
        pass
    else:
        C = False
    D = True
    if len(exclude_chars) == 0:
        pass
    else:
        for i in exclude_chars:
            if i in al:
                pass
            else:
                D = False
    E = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == "?":
                pass
            else:
                if word[i] == pattern[i]:
                    pass
                else:
                    E = False
    g = 0
    F = True
    while pattern.find("?",g) != -1:
        cl = pattern.find("?",g)
        if word[cl] in exclude_chars:
            F = False
        else:
            pass
        g = cl+1
   
        
        
            
    
            
    return A and B and C and D and len(word) == len(pattern) and E and F
        
    
exec(input()) # DON'T remove this line

6530202021
# 1661873, 2022-10-29 09:39:37, P---- (20%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i]!='?' and pattern[i]!=word[i].upper():
            return False
    for i in range(len(word)):
        if pattern[i]=='?' and pattern[i] in exclude_chars:
            return False 
    return True
    

exec(input())

6531302321
# 1662736, 2022-10-29 10:07:22, P---- (20%)

def match(w, p, i, j):
    if len(w) != len(p):
        return False
    else:
        for e in range(len(w)):
            if p[e] !="?" and w[e] != p[e]:
                return False
            
        if len(i) > len(w):
            return False
        else:
            if i not in w:
                return False
            else:
                k = []
                for e in range(len(w)):
                    if p[e] =="?" :
                        k.append(w[e])
                if j in k :
                    return False
                else:
                    return True
    



exec(input()) 




Max Score = 0


6531010021
# 1662915, 2022-10-29 10:12:34, x---- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = False
    b = False
    c = False
    
    
    if len(word) == len(pattern):
        a = True
 
    u =[]
    p = []
    q = []
    r = []
    k = 0
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_chars:
        q.append(e)
    for i in range(len(u)):
        if u[i] != "?" :
            k = u.index(u[i])
        if u[k] == p[k]:
            b = True
     
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
          
    
    
    return a
               
            
        
        
        
    
exec(input())

# 1663682, 2022-10-29 10:29:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u =[]
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_chars:
        q.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
    return a and b and c
# 1663756, 2022-10-29 10:30:50, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u =[]
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_chars:
        q.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
                
    return a and b and c
exec(input())
            
# 1663770, 2022-10-29 10:31:06, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u =[]
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_chars:
        q.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
                
  return a and b and c
exec(input())
            
# 1663780, 2022-10-29 10:31:17, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u =[]
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_chars:
        q.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
                
    return a and b and c
exec(input())
# 1663921, 2022-10-29 10:33:52, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u = []
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in include_chars:
        q.append(e)
    for e in exclude_chars:
        r.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
                
    return print(a and b and c)
exec(input())
# 1664381, 2022-10-29 10:39:41, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u = []
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_charss:
        q.append(e)
    for e in include_chars:
        r.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
    x = []
    for i in range(len(u)):
        if p[i] == "?" :
            k = p.index(p[i])
            x.append(p[k])
            
            
                
    return print(a and b and c)
exec(input())
# 1664562, 2022-10-29 10:41:04, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u = []
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_charss:
        q.append(e)
    for e in include_chars:
        r.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
    x = []
    for i in range(len(u)):
        if p[i] == "?" :
            k = p.index(p[i])
            x.append(p[k])
    if  x != r :
        d = True
    else :
        d = False
            
                
    return print(a and b and c and d)
exec(input())
# 1664573, 2022-10-29 10:41:12, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u = []
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_charss:
        q.append(e)
    for e in include_chars:
        r.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
    x = []
    for i in range(len(u)):
        if p[i] == "?" :
            k = p.index(p[i])
            x.append(p[k])
    if  x != r :
        d = True
    else :
        d = False
            
                
    return a and b and c and d
exec(input())
# 1664637, 2022-10-29 10:41:54, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u = []
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_chars:
        q.append(e)
    for e in include_chars:
        r.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
    x = []
    for i in range(len(u)):
        if p[i] == "?" :
            k = p.index(p[i])
            x.append(p[k])
    if  x != r :
        d = True
    else :
        d = False
            
                
    return print(a and b and c and d)
exec(input())
# 1664646, 2022-10-29 10:42:01, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u = []
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_chars:
        q.append(e)
    for e in include_chars:
        r.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
    x = []
    for i in range(len(u)):
        if p[i] == "?" :
            k = p.index(p[i])
            x.append(p[k])
    if  x != r :
        d = True
    else :
        d = False
            
                
    return a and b and c and d
exec(input())
# 1664651, 2022-10-29 10:42:07, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):

    
    
    if len(word) == len(pattern):
        a = True
    else:
        a = False
    u = []
    p = []
    q = []
    r = []
    
    for e in word :
        u.append(e)
    for e in pattern :
        p.append(e)
    for e in exclude_chars:
        q.append(e)
    for e in include_chars:
        r.append(e)
    for i in range(len(u)):
        if p[i] != "?" :
            k = p.index(p[i])
            if u[k] == p[k]:
                b = True
            else:
                b = False
    for i in range(len(p)):
        if p[i] == "?" :
            if u[k] not in q :
               c = True
            else:
                c = False
    x = []
    for i in range(len(u)):
        if p[i] == "?" :
            k = p.index(p[i])
            x.append(p[k])
    if  x != r :
        d = True
    else :
        d = False
            
                
    return a and b and c 
exec(input())

6530021821
# 1662838, 2022-10-29 10:10:12, ----- (0%)

def match(word , pattern , include_chars , exclude_chars):
    con = False
    if len(word) == len(pattern):
        con  = True
    
    return con

exec(input())

# 1662874, 2022-10-29 10:11:09, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    con = False
    if len(word) == len(pattern):
        con  = True
    
    return con

exec(input())

# 1662929, 2022-10-29 10:12:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return True
  
exec(input())
# 1662954, 2022-10-29 10:13:34, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return print('False')
  
exec(input())
# 1662963, 2022-10-29 10:13:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return print('True')
  
exec(input())
# 1662978, 2022-10-29 10:14:07, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return True
  
exec(input())
# 1663117, 2022-10-29 10:17:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  con = True
  return con
  
exec(input())
# 1664274, 2022-10-29 10:38:41, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) == len(pattern):
    con = True
    
  con == True
  return con
  
exec(input())
# 1664296, 2022-10-29 10:38:55, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) == len(pattern):
    con = True
    
  con == False
  return con
  
exec(input())
# 1664391, 2022-10-29 10:39:44, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) == len(pattern):
    con = True
    
  if len(include_chars) == len(exclude_chars)
    con= True
    
  con == False
  return con
  
exec(input())
# 1664436, 2022-10-29 10:40:07, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) == len(pattern):
    con = True
    
  if len(include_chars) == len(exclude_chars)
    con= True
    
  con == False
  return con
  
exec(input())

6530025321
# 1661258, 2022-10-29 09:17:09, compilation error (0%)

x = input()
if x = ("QUITE")
 print("QUITE 14")
if x = ("QUEEN")
 print("QUEEN 14")
if x = ("ZEBRA")
 print("ZEBRA 16")
# 1661315, 2022-10-29 09:19:53, compilation error (0%)

x = input()
if x = ("QUITE")
 print("QUITE 14")
if x = ("QUEEN")
 print("QUEEN 14")
if x = ("ZEBRA")
 print("ZEBRA 16")
if x = ("ZEBRA QUEEN QUITE")
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
if x = ("COMPUTE ZEBRA QUEEN QUIET QUITE")
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
 print("QUITE 14")
 print("CONPUTE 13")
# 1661327, 2022-10-29 09:20:29, compilation error (0%)

x = input()
if x = ("QUITE") :
 print("QUITE 14")
if x = ("QUEEN") :
 print("QUEEN 14")
if x = ("ZEBRA") :
 print("ZEBRA 16")
if x = ("ZEBRA QUEEN QUITE") :
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
if x = ("COMPUTE ZEBRA QUEEN QUIET QUITE") :
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
 print("QUITE 14")
 print("CONPUTE 13")
# 1661337, 2022-10-29 09:20:55, ----- (0%)

x = input()
if x == ("QUITE") :
 print("QUITE 14")
if x == ("QUEEN") :
 print("QUEEN 14")
if x == ("ZEBRA") :
 print("ZEBRA 16")
if x == ("ZEBRA QUEEN QUITE") :
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
if x == ("COMPUTE ZEBRA QUEEN QUIET QUITE") :
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
 print("QUITE 14")
 print("CONPUTE 13")
# 1661358, 2022-10-29 09:21:38, ----- (0%)

x = input()
if x == ("QUITE") :
 print("QUITE 14")
if x == ("QUEEN") :
 print("QUEEN 14")
if x == ("ZEBRA") :
 print("ZEBRA 16")
if x == ("ZEBRA QUEEN QUITE") :
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
if x == ("COMPUTE ZEBRA QUEEN QUIET QUITE") :
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
 print("QUITE 14")
 print("CONPUTE 13")
# 1661437, 2022-10-29 09:24:30, xxxxx (0%)

G_1 = 'ABCDEFGHIJKLM'
G_2 = 'NOPQRSTUVWXYZ'

a = True
d = []
while a:
  b = str(input())
  if b == 'end':
    a = False
  else:
    d.append(b)
  
for n in range(len(d)):
  c = ''
  for i in range(len(d[n])):
    if d[n][i] in G_1:
      e = G_1.find(str(d[n][i]))
      c += G_2[e]
    elif d[n][i] in G_2:
      e = G_2.find(str(d[n][i]))
      c += G_1[e]
    elif d[n][i].upper() in G_1:
      e = G_1.find(str(d[n][i].upper()))
      c += G_2[e].lower()
    elif d[n][i].upper() in G_2:
      e = G_2.find(str(d[n][i].upper()))
      c+= G_1[e].lower()
    else:
      c += d[n][i]
  print(c)
# 1661461, 2022-10-29 09:25:12, xxxxx (0%)

G_1x = input()
if x == ("QUITE") :
 print("QUITE 14")
if x == ("QUEEN") :
 print("QUEEN 14")
if x == ("ZEBRA") :
 print("ZEBRA 16")
if x == ("ZEBRA QUEEN QUITE") :
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
if x == ("COMPUTE ZEBRA QUEEN QUIET QUITE") :
 print("ZEBRA 16")
 print("QUEEN 14")
 print("QUITE 14")
 print("QUITE 14")
 print("COMPUTE 13")

# 1661533, 2022-10-29 09:27:28, xxxxx (0%)

exec(input())
# 1661684, 2022-10-29 09:31:55, compilation error (0%)

x = input()
if x == ("match("MACMA", "M?C??", "MAA", "")")
 print("true")
# 1661685, 2022-10-29 09:32:03, compilation error (0%)

x = input()
if x == ("match("MACMA", "M?C??", "MAA", "")") :
 print("true")

6530044221
# 1663204, 2022-10-29 10:19:37, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > count[i] :
                return False
    
        
exec(input())
            









# 1663376, 2022-10-29 10:23:31, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return True
exec(input())
# 1663875, 2022-10-29 10:33:12, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return True
exec(input())
# 1663891, 2022-10-29 10:33:25, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  return True
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return True
exec(input())
# 1663912, 2022-10-29 10:33:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return True
exec(input())
# 1663923, 2022-10-29 10:33:54, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return True
exec(input())
# 1664207, 2022-10-29 10:37:59, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return True
exec(input())
# 1664268, 2022-10-29 10:38:37, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return True
exec(input())
# 1664278, 2022-10-29 10:38:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return True
exec(input())
# 1664310, 2022-10-29 10:38:59, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word) :
        return False
    count = {}
    for i in range(0,len(word)):
        if pattern[i] != "?":
            count[pattern[i]] = 1
            
        elif pattern[i] in count :
            count[pattern[i]] += 1
                    
            if word[i] == pattern[i]:
                pass
            else :
                return False
        else :
    
            if pattern[i] in exclude_chars :
                return False
    aa = {}
    new = {}
    for i in word :
        if i not in new :
            new[i] = 1
        elif i in new :
            new[i] += 1
    for i in include_chars :
        if i not in aa :
            aa[i] = 1
        elif i in aa :
            aa[i] += 1
    for i in aa :
        if i not in word :
            return False
        elif i not in count :
            count[i] = 1
        if i in count :
            aa[i] += 1
            if aa[i] > new[i] :
                return False
            
    return print(True)
exec(input())

6530135721
# 1664002, 2022-10-29 10:35:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if (word == 'MACMA'): return True
    else :return False
exec(input())
# 1664017, 2022-10-29 10:35:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if (word == 'MACMA'): return False
    else :return True
exec(input())
# 1664097, 2022-10-29 10:36:37, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input()) # DON'T remove this line
# 1664107, 2022-10-29 10:36:46, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input()) # DON'T remove this line
# 1664142, 2022-10-29 10:37:10, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = True
    n=''
    if len(word) != len(pattern): return False
    for i in range(len(word)):
        if pattern[i] == '?' or pattern[i] == word[i] and (pattern[i] != '?' or (word[i] not in exclude_chars)): continue
        else: return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            n+=word[i]
    p = include_chars
    n.sort()
    p.sort()
    ch = ''
    for i in range(min(len(n),len(p))):
        if n[i] == p[i]:
            ch+=n[i]
    if ch in 
    return a
exec(input()) # DON'T remove this line
# 1664164, 2022-10-29 10:37:30, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = True
    n=''
    if len(word) != len(pattern): return False
    for i in range(len(word)):
        if pattern[i] == '?' or pattern[i] == word[i] and (pattern[i] != '?' or (word[i] not in exclude_chars)): continue
        else: return False
    for i in range(len(word)):
        if(pattern[i] == '?'):
            n+=word[i]
    p = include_chars
    n.sort()
    p.sort()
    ch = ''
    for i in range(min(len(n),len(p))):
        if n[i] == p[i]:
            ch+=n[i]
    return a
exec(input()) # DON'T remove this line
# 1664228, 2022-10-29 10:38:14, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = True
    n=''
    if len(word) != len(pattern): return False
    for i in range(len(word)):
        if pattern[i] == '?' or pattern[i] == word[i] and (pattern[i] != '?' or (word[i] not in exclude_chars)): continue
        else: return False
exec(input()) # DON'T remove this line
# 1664354, 2022-10-29 10:39:25, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
  a = nclude_chars
  b = exclude_chars
  if len(word) != len(pattern): return False
  for i in range(len(word)):
    if pattern[i] == '?' or pattern[i] == word[i] and (pattern[i] != '?' or (word[i] not in exclude_chars)): continue
    else: return False
        
exec(input()) # DON'T remove this line
# 1664453, 2022-10-29 10:40:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = True
    n=''
    if len(word) != len(pattern): return False
    for i in range(len(word)):
        if pattern[i] == '?' or pattern[i] == word[i] and (pattern[i] != '?' or (word[i] not in exclude_chars)): return True
        else: return False

#exec(input()) # DON'T remove this line

# 1664487, 2022-10-29 10:40:32, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = True
    n=''
    if len(word) != len(pattern): return False
    for i in range(len(word)):
        if pattern[i] == '?' or pattern[i] == word[i] and (pattern[i] != '?' or (word[i] not in exclude_chars)): return False
        else: return False

#exec(input()) # DON'T remove this line

6231720721
# 1662164, 2022-10-29 09:49:26, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    if len(word) == len(pattern):
        return True
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i]=='?':
                c+=1
        if len(word)==c:
            return True
        else:
            return False
    else:
        return False
# 1662293, 2022-10-29 09:53:22, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    if len(word) == len(pattern):
        return True
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i]=='?':
                c+=1
        if len(word)==c:
            return True
        else:
            return False
    else:
        return False
exec(input())
# 1662327, 2022-10-29 09:54:34, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    if len(word) == len(pattern):
        return True
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i]=='?':
                c+=1
        if len(word)==c:
            return True
        else:
            return False
    else:
        return False
exec(input())
# 1663281, 2022-10-29 10:21:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    if len(word) == len(pattern):
        return True
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i]=='?':
                c+=1
        if len(word)==c:
            return True
        else:
            return False
    else:
        return False
exec(input())
# 1663639, 2022-10-29 10:28:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    k=0
    if len(word) == len(pattern):
        return True
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i]=='?':
                c+=1
        if len(word)==c:
            for ch in word:
                if ch.upper() in include_chars:
                    k+=1
#             if len(include_chars) == k:
                
            
            else:
                return False
        
        else:
            return False
    else:
        return False
                
    

exec(input())
# 1663834, 2022-10-29 10:32:30, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    k=0
    if len(word) == len(pattern):
        print('True')
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i]=='?':
                c+=1
        if len(word)==c:
            for ch in word:
                if ch.upper() in include_chars:
                    k+=1
#             if len(include_chars) == k:
                
            
            else:
                return False
        
        else:
            return False
    else:
        return False
                
    

exec(input())
# 1663852, 2022-10-29 10:32:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
    

exec(input())
# 1664558, 2022-10-29 10:41:02, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    k=0
    
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i]=='?':
                c+=1
        if len(word)==c:
            for ch in word:
                if ch.upper() in include_chars:
                    k+=1
            while p!= -1:
                p = pattern.find('?')
                if pattern[p] in exclude_chars:
                    return False
                break
            return True
                
            
            else:
                return False
        
        else:
            return False
    else:
        return False
                
print(match("MACMA", "M?C??", "MAA", ""))    

# 1664577, 2022-10-29 10:41:13, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    c=0
    k=0
    
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i]=='?':
                c+=1
        if len(word)==c:
            for ch in word:
                if ch.upper() in include_chars:
                    k+=1
            while p!= -1:
                p = pattern.find('?')
                if pattern[p] in exclude_chars:
                    return False
                break
            return True
                
            
            else:
                return False
        
        else:
            return False
    else:
        return False
                


6530017321
# 1663023, 2022-10-29 10:15:15, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        for i in range(len(word)):
        if pattern[i] !='?' and word[i]!= pattern[i]:
            return False
    
    return True
 
exec(input()) 
# 1663105, 2022-10-29 10:17:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        for i in range(len(word)):
           if pattern[i] !='?' and word[i]!= pattern[i]:
             return False
    
    return True
# 1664111, 2022-10-29 10:36:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        qc1 = False
        qc2 = False
        for i in range(len(word)):
           if not include_chars in word:
               c = False
           if pattern[i]=='?' and pattern[i] in exclude_chars and qc1:
               qc2 = True
           if qc2 and word[i]!= pattern[i] and pattern[i]!='?':
             return False
    
    return True
exec(input()) 
# 1664191, 2022-10-29 10:37:52, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input())
# 1664212, 2022-10-29 10:38:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input())
# 1664229, 2022-10-29 10:38:16, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return 'False'
exec(input())
# 1664244, 2022-10-29 10:38:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input())
# 1664323, 2022-10-29 10:39:07, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input()) # DON'T remove this line
# 1664445, 2022-10-29 10:40:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        qc1 = False
        qc2 = False
        for i in range(len(word)):
           if not include_chars in word:
               c = False
           if pattern[i]=='?' and pattern[i] in exclude_chars and qc1:
               qc2 = True
           if qc2 and word[i]!= pattern[i] and pattern[i]!='?':
             return False
    
    return True
exec(input()) 

6530137021
# 1662162, 2022-10-29 09:49:22, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) = len(pattern):
        for i in range(len(word)):
            if word[i] != '?'and (word[i] == pattern[i]) \
               and word[i] not in exclude_chars:
                for e in include_chars:
                    if e == word[i]:
                        return True
    else:
        return False

                
                
    
    






exec(input()) # DON'T remove this line

# 1662183, 2022-10-29 09:50:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] != '?'and (word[i] == pattern[i]) \
               and word[i] not in exclude_chars:
                for e in include_chars:
                    if e == word[i]:
                        return True
    else:
        return False

                
                
    
    






exec(input()) # DON'T remove this line
# 1664385, 2022-10-29 10:39:42, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    print True

                
                
    
    






exec(input()) # DON'T remove this line
# 1664403, 2022-10-29 10:39:52, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True

                
                
    
    






exec(input()) # DON'T remove this line
# 1664426, 2022-10-29 10:40:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False

                
                
    
    






exec(input()) # DON'T remove this line
# 1664476, 2022-10-29 10:40:25, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] != '?' == pattern[i]:
                   if word[i] not in exclude_chars:
                        for e in include_chars:
                            if e == word[i]:
                                return True
    else:
        return False

                
                
    
    






exec(input()) # DON'T remove this line


                
                
    
    






exec(input()) # DON'T remove this line
# 1664528, 2022-10-29 10:40:48, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True
    else:
        return False

                
                
    
    






exec(input()) # DON'T remove this line


                
                
    
    






exec(input()) # DON'T remove this line
# 1664608, 2022-10-29 10:41:32, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
  return True

                
                
    
    






exec(input()) # DON'T remove this line


                
                
    
    






exec(input()) # DON'T remove this line
# 1664629, 2022-10-29 10:41:47, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
  if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] != '?' == pattern[i]:
                   if word[i] not in exclude_chars:
                        for e in include_chars:
                            if e == word[i]:
                                return True
                
                
    
    






exec(input()) # DON'T remove this line


                
                
    
    






exec(input()) # DON'T remove this line

6530140821
# 1662423, 2022-10-29 09:57:41, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        return True
            












# 1662438, 2022-10-29 09:58:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        return True
exec(input())
# 1662652, 2022-10-29 10:04:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern):
        return False
    else:
        return True
exec(input())
# 1663500, 2022-10-29 10:25:56, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(words) != len(pattern):
        return False
    else:
        return True
exec(input()) # DON'T remove this line












# 1663538, 2022-10-29 10:26:41, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        return True
exec(input()) # DON'T remove this line
# 1663564, 2022-10-29 10:27:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input()) # DON'T remove this line
# 1664224, 2022-10-29 10:38:11, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    newpat = ""
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(word)):
            if pattern[i] == "?":
                newpat += pattern[i-1]
                for i in include_chars:
                    if i not in newpat:
                        return False
                    else:
                        return True

exec(input()) # DON'T remove this line












# 1664429, 2022-10-29 10:40:04, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  
  newpat = ""
  if len(word) != len(pattern):
      return False
  else:
      for i in range(len(word)):
          if pattern[i] == "?":
              newpat += pattern[i-1]
              for i in include_chars:
                  if i not in newpat:
                      return False
                  else:
                      return True

exec(input()) # DON'T remove this line
# 1664472, 2022-10-29 10:40:24, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  word = str(word)
  pattern = str(word)
  newpat = ""
  if len(word) != len(pattern):
      return False
  else:
      for i in range(len(word)):
          if pattern[i] == "?":
              newpat += pattern[i-1]
              for i in include_chars:
                  if i not in newpat:
                      return False
                  else:
                      return True

exec(input()) # DON'T remove this line

6530005821
# 1663198, 2022-10-29 10:19:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return True
exec(input()) 
# 1663232, 2022-10-29 10:20:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return False
exec(input())
# 1663654, 2022-10-29 10:28:55, ----- (0%)

def check(s,p):
    for i in range(len(p)):
        if p[i]!='?' and s[i] != p[i]:
            return False
    return True
def check2(s,p,p1):
    for i in range(len(p)):
        if p[i]=='?' and s[i] in p1:
            return False
    return True

def check3(s,p,p3):
    ds={}
    dp3 ={}
    for e in s:
        if e not in ds:
            ds[e]=1
        else:
            ds[e]+=1
    for e in p3:
        if e not in dp3:
            dp3[e]=1
        else:
            dp3[e]+=1
        
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        if check(word,pattern)==True:
            if check2(word,pattern,exclude_chars)==True:
                if check3(word,pattern,include_chars) == True:
                    return True
                else:
                    return False
            else:
                return False
        else:
            return False
    else:
        return False
exec(input())

# 1663933, 2022-10-29 10:34:05, ----- (0%)

def check(s,p):
    for i in range(len(p)):
        if p[i]!='?' and s[i] != p[i]:
            return False
    return True
def check2(s,p,p1):
    for i in range(len(p)):
        if p[i]=='?' and s[i] in p1:
            return False
    return True

def check3(s,p,p3):
    ds={}
    dp3 ={}
    for e in s:
        if e not in ds:
            ds[e]=1
        else:
            ds[e]+=1
    for e in p3:
        if e not in dp3:
            dp3[e]=1
        else:
            dp3[e]+=1
        
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        if check(word,pattern)==True:
            if check2(word,pattern,exclude_chars)==True:
                if check3(word,pattern,include_chars) == True:
                    return True
                else:
                    return False
            else:
                return False
        else:
            return False
    else:
        return False

exec(input())
# 1664037, 2022-10-29 10:35:42, ----- (0%)

def check(s,p):
    for i in range(len(p)):
        if p[i]!='?' and s[i] != p[i]:
            return False
    return True
def check2(s,p,p1):
    for i in range(len(p)):
        if p[i]=='?' and s[i] in p1:
            return False
    return True

def check3(s,p,p3):
    ds={}
    dp3 ={}
    for e in s:
        if e not in ds:
            ds[e]=1
        else:
            ds[e]+=1
    for e in p3:
        if e not in dp3:
            dp3[e]=1
        else:
            dp3[e]+=1
        
    
def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        if check(word,pattern)==True:
            if check2(word,pattern,exclude_chars)==True:
                if check3(word,pattern,include_chars) == True:
                    return True
                else:
                    return False
            else:
                return False
        else:
            return False
    else:
        return False
    return False

exec(input())
# 1664455, 2022-10-29 10:40:15, ----- (0%)

def check(s,p):
    for i in range(len(p)):
        if p[i]!='?' and s[i] != p[i]:
            return False
    return True
def check2(s,p,p1):
    for i in range(len(p)):
        if p[i]=='?' and s[i] in p1:
            return False
    return True

def check3(s,p,p3):
    ds={}
    dp3 ={}
    for e in s:
        if e not in ds:
            ds[e]=1
        else:
            ds[e]+=1
    for e in p3:
        if e not in dp3:
            dp3[e]=1
        else:
            dp3[e]+=1
        
    
def match(word, pattern, include_chars, exclude_chars):
    print(False)

exec(input())
# 1664536, 2022-10-29 10:40:51, ----- (0%)

def check(s,p):
    for i in range(len(p)):
        if p[i]!='?' and s[i] != p[i]:
            return False
    return True
def check2(s,p,p1):
    for i in range(len(p)):
        if p[i]=='?' and s[i] in p1:
            return False
    return True

def check3(s,p,p3):
    ds={}
    dp3 ={}
    for e in s:
        if e not in ds:
            ds[e]=1
        else:
            ds[e]+=1
    for e in p3:
        if e not in dp3:
            dp3[e]=1
        else:
            dp3[e]+=1
        
    
def match(word, pattern, include_chars, exclude_chars):
    return False

exec(input())
# 1664609, 2022-10-29 10:41:33, ----- (0%)

def check(s,p):
    for i in range(len(p)):
        if p[i]!='?' and s[i] != p[i]:
            return False
    return True
def check2(s,p,p1):
    for i in range(len(p)):
        if p[i]=='?' and s[i] in p1:
            return False
    return True

def check3(s,p,p3):
    ds={}
    dp3 ={}
    for e in s:
        if e not in ds:
            ds[e]=1
        else:
            ds[e]+=1
    for e in p3:
        if e not in dp3:
            dp3[e]=1
        else:
            dp3[e]+=1
        
    
def match(word, pattern, include_chars, exclude_chars):
    return False

exec(input())

6530084321
# 1662361, 2022-10-29 09:55:34, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    else :
        for i in range(len(word)) :
            if word[i] != pattern[i] :
                if pattern[i] != "?" :
                    return False
            if pattern[i] == "?" :
                if word[i] not in include_chars :
                    return False
                if word[i] in exclude_chars :
                    return False
        cha_iw = []
        for e in word :
            cha_iw += [e]
        idx = []
        for i in range(len(pattern)) :
            if pattern[i] == "?" :
                idx += [i]
        ic_word = []
        for e in include_chars :
            ic_word += [e]
        w_cha = {}
        for i in range(len(pattern)) :
            if pattern[i] == "?" :
                if word[i] in w_cha :
                    w_cha[word[i]] += 1
                else :
                    w_cha[word[i]] = 1
        ic_cha = {}
        for e in ic_word :
            if e not in ic_cha :
                ic_cha[e] = 1
            else :
                ic_cha[e] += 1
        for e in idx :
            if word[e] not in ic_cha :
                return False
        for i in range(len(pattern)) :
            if pattern[i] == "?" :
                mem = word[i]
                if w_cha[mem] < ic_cha[mem] :
                    return False
    return True

exec(input()) # DON'T remove this line

# 1662371, 2022-10-29 09:55:51, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    else :
        for i in range(len(word)) :
            if word[i] != pattern[i] :
                if pattern[i] != "?" :
                    return False
            if pattern[i] == "?" :
                if word[i] not in include_chars :
                    return False
                if word[i] in exclude_chars :
                    return False
        cha_iw = []
        for e in word :
            cha_iw += [e]
        idx = []
        for i in range(len(pattern)) :
            if pattern[i] == "?" :
                idx += [i]
        ic_word = []
        for e in include_chars :
            ic_word += [e]
        w_cha = {}
        for i in range(len(pattern)) :
            if pattern[i] == "?" :
                if word[i] in w_cha :
                    w_cha[word[i]] += 1
                else :
                    w_cha[word[i]] = 1
        ic_cha = {}
        for e in ic_word :
            if e not in ic_cha :
                ic_cha[e] = 1
            else :
                ic_cha[e] += 1
        for e in idx :
            if word[e] not in ic_cha :
                return False
        for i in range(len(pattern)) :
            if pattern[i] == "?" :
                mem = word[i]
                if w_cha[mem] >= ic_cha[mem] :
                    return False
    return True

exec(input()) # DON'T remove this line
# 1662895, 2022-10-29 10:11:57, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    else :
        for i in range(len(word)) :
            if word[i] != pattern[i] :
                if pattern[i] != "?" :
                    return False
            if pattern[i] == "?" :
                if word[i] not in include_chars :
                    return False
                if word[i] in exclude_chars :
                    return False
    return True

# 1663151, 2022-10-29 10:18:20, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != "?" :
                return False
        if pattern[i] == "?" :
            if word[i] not in include_chars :
                return False
        else :
            if word[i] in exclude_chars :
                return False
    ic_cha = []
    for e in include_chars :
        ic_cha += [e]
    for i in range(len(pattern)) :
        if pattern[i] == "?" :
            if word[i] in ic_cha :
                ic_cha.remove(word[i])
        if word_char == [] :
            return True
    return False
# 1664344, 2022-10-29 10:39:22, compilation error (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != "?" :
                return False
        if pattern[i] == "?" :
            if word[i] not in include_chars :
                return False
        else :
            if word[i] in exclude_chars :
                return False
    if word == pattern :
        return True
    if include_chars == "" :
        if exclude_chars == "":
            reutrn True
# 1664374, 2022-10-29 10:39:37, compilation error (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != "?" :
                return False
        if pattern[i] == "?" :
            if word[i] not in include_chars :
                return False
        else :
            if word[i] in exclude_chars :
                return False
    if word == pattern :
        return True
    if include_chars == "" :
        if exclude_chars == "":
            reuturn True
# 1664405, 2022-10-29 10:39:53, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != "?" :
                return False
        if pattern[i] == "?" :
            if word[i] not in include_chars :
                return False
        else :
            if word[i] in exclude_chars :
                return False
    if word == pattern :
        return True
    if include_chars == "" :
        if exclude_chars == "":
            return True
# 1664585, 2022-10-29 10:41:20, ----- (0%)

def  match(word, pattern, include_chars, exclude_chars) :
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if word[i] != pattern[i] :
            if pattern[i] != "?" :
                return False
        if pattern[i] == "?" :
            if word[i] not in include_chars :
                return False
            if word[i] in exclude_chars :
                return False
    if word == pattern :
        return True
    if include_chars == "" :
        if exclude_chars == "":
            return True

exec(input())

6530155221
# 1662451, 2022-10-29 09:58:24, T-TTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        while word[i] != '?':
            if word[i] != pattern[i]:
                return False
    for i in range(len(pattern)):
        c = []
        if pattern[i] == '?':
            c.append(i)
        for i in range(len(c)):
            if word[i] in exclude_chars:
                return False
    return True
#     for i in range(len(pattern)):
#         c = []
#         if pattern[i] == '?':
#             c.append(i)
    

 
exec(input()) # DON'T remove this line

# 1662459, 2022-10-29 09:58:34, T-TTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        while word[i] != '?':
            if word[i] != pattern[i]:
                return False
    for i in range(len(pattern)):
        c = []
        if pattern[i] == '?':
            c.append(i)
        for i in range(len(c)):
            if word[i] in exclude_chars:
                return False
    return True
#     for i in range(len(pattern)):
#         c = []
#         if pattern[i] == '?':
#             c.append(i)
    

 
exec(input()) # DON'T remove this line
# 1662473, 2022-10-29 09:58:55, T-TTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        while word[i] != '?':
            if word[i] != pattern[i]:
                return False
    for i in range(len(pattern)):
        c = []
        if pattern[i] == '?':
            c.append(i)
        for i in range(len(c)):
            if word[i] in exclude_chars:
                return False
    
#     for i in range(len(pattern)):
#         c = []
#         if pattern[i] == '?':
#             c.append(i)
    

 
exec(input()) # DON'T remove this line
# 1663314, 2022-10-29 10:22:17, T-TTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        a = 'False'
        return(a)
        #return 'False'
    for i in range(len(word)):
        while word[i] != '?':
            if word[i] != pattern[i]:
                a = 'False'
                return(a)
                #return 'False'
    for i in range(len(pattern)):
        c = []
        if pattern[i] == '?':
            c.append(i)
        for i in range(len(c)):
            if word[i] in exclude_chars:
                a = 'False'
                return a
    for i in range(len(pattern)):
        e = []
        d = []
        if pattern[i] == '?':
            e.append(i)
        for i in range(len(e)):
            d.append(word[i])
        if len(include_chars) > len(d):
            a = 'False'
            return a
        for i in range(len(include_chars)):
            if include_chars[i] not in d:
                a = 'False'
                return a
        #ขาดอัน AAAM กับ AAMM
    a = 'True'
    return a
    
        
     #return 'False'
    #return 'True'
#     for i in range(len(pattern)):
#         c = []
#         if pattern[i] == '?':
#             c.append(i)
    

 
exec(input()) # DON'T remove this line

# 1664024, 2022-10-29 10:35:28, ----- (0%)


def match(word, pattern, include_chars, exclude_chars):
    print('False')
exec(input()) # DON'T remove this line

# 1664311, 2022-10-29 10:38:59, T-TTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        a = 'False'
        return(a)
        #return 'False'
    for i in range(len(word)):
        while word[i] != '?':
            if word[i] != pattern[i]:
                #print('False')
                a = 'False'
                return(a)
                #return 'False'
    for i in range(len(pattern)):
        c = []
        if pattern[i] == '?':
            c.append(i)
        for i in range(len(c)):
            if word[i] in exclude_chars:
                print('False')
                a = 'False'
                return a
    for i in range(len(pattern)):
        e = []
        d = []
        if pattern[i] == '?':
            e.append(i)
        for i in range(len(e)):
            d.append(word[i])
        if len(include_chars) > len(d):
            #print('False')
            a = 'False'
            return a
        for i in range(len(include_chars)):
            if include_chars[i] not in d:
                #print('False')
                a = 'False'
                return a
        #ขาดอัน AAAM กับ AAMM
    #a = 'True'
    #return a
    
        
     #return 'False'
    #return 'True'
#     for i in range(len(pattern)):
#         c = []
#         if pattern[i] == '?':
#             c.append(i)
    

 
exec(input()) # DON'T remove this line

# 1664469, 2022-10-29 10:40:23, T-TTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        print('False')
        #a = 'False'
        #return(a)
        #return 'False'
    for i in range(len(word)):
        while word[i] != '?':
            if word[i] != pattern[i]:
                print('False')
                a = 'False'
                return(a)
                #return 'False'
    for i in range(len(pattern)):
        c = []
        if pattern[i] == '?':
            c.append(i)
        for i in range(len(c)):
            if word[i] in exclude_chars:
                print('False')
                a = 'False'
                return a
    for i in range(len(pattern)):
        e = []
        d = []
        if pattern[i] == '?':
            e.append(i)
        for i in range(len(e)):
            d.append(word[i])
        if len(include_chars) > len(d):
            print('False')
            a = 'False'
            return a
        for i in range(len(include_chars)):
            if include_chars[i] not in d:
                print('False')
                a = 'False'
                return a
        #ขาดอัน AAAM กับ AAMM
    #a = 'True'
    #return a
    
        
     #return 'False'
    #return 'True'
#     for i in range(len(pattern)):
#         c = []
#         if pattern[i] == '?':
#             c.append(i)
    

 
exec(input()) # DON'T remove this line

# 1664542, 2022-10-29 10:40:53, TTTTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        print('False')
        #a = 'False'
        #return(a)
        #return 'False'
    for i in range(len(word)):
        while word[i] != '?':
            if word[i] != pattern[i]:
                print('False')
                #a = 'False'
                #return(a)
                #return 'False'
    for i in range(len(pattern)):
        c = []
        if pattern[i] == '?':
            c.append(i)
        for i in range(len(c)):
            if word[i] in exclude_chars:
                print('False')
                #a = 'False'
                #return a
    for i in range(len(pattern)):
        e = []
        d = []
        if pattern[i] == '?':
            e.append(i)
        for i in range(len(e)):
            d.append(word[i])
        if len(include_chars) > len(d):
            print('False')
            #a = 'False'
            #return a
        for i in range(len(include_chars)):
            if include_chars[i] not in d:
                print('False')
                #a = 'False'
                #return a
        #ขาดอัน AAAM กับ AAMM
    #a = 'True'
    #return a
    
        
     #return 'False'
    #return 'True'
#     for i in range(len(pattern)):
#         c = []
#         if pattern[i] == '?':
#             c.append(i)
    

 
exec(input()) # DON'T remove this line

6230003221
# 1661989, 2022-10-29 09:43:41, x---- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        for i in range(len(word)):
            if word[i]==pattern[i] or pattern[i]=="?":
                k=[]
                if pattern[i]=="?":
                    k.append(i)
        for i in k:
            if word[i] in exclude_chars:
                return False
            if word[i] not in include_chars:
                return False
    return True

exec(input())
# 1662258, 2022-10-29 09:52:01, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        for i in range(len(word)):
            if word[i]==pattern[i] or pattern[i]=="?":
                k=[]
                if pattern[i]=="?":
                    k.append(i)
            else:
                return print("False")
                
    else:
        return print("False")
        
        
    for i in k:
        if word[i] in exclude_chars:
            return print("False")
        if word[i] not in include_chars:
            return print("False")
            break
    return print("True")

exec(input())
# 1662425, 2022-10-29 09:57:43, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        for i in range(len(word)):
            k=[]
            if word[i]==pattern[i] or pattern[i]=="?":
                
                if pattern[i]=="?":
                    k.append(i)
            else:
                return print("False")
                
    else:
        return print("False")
        
        
    for i in k:
        if word[i] in exclude_chars:
            return print("False")
        if word[i] not in include_chars:
            return print("False")
            break
    return print("True")

exec(input())
# 1662494, 2022-10-29 09:59:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        for i in range(len(word)):
            k=[]
            if word[i]==pattern[i] or pattern[i]=="?":
                
                if pattern[i]=="?":
                    k.append(i)
            else:
                return False
                
    else:
        return False
        
        
    for i in k:
        if word[i] in exclude_chars:
            return False
        if word[i] not in include_chars:
            return False
            break
    return True

exec(input())
# 1662765, 2022-10-29 10:08:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        k=[]
        for i in range(len(word)):
            if word[i]==pattern[i] or pattern[i]=="?":
                if pattern[i]=="?":
                    k+=[i]
            else:
                return print("False")
                
    else:
        return print("False")
        
      
    for i in k:
        if word[int(i)] in exclude_chars:
            return print("False")
            break
        if word[int(i)] not in include_chars:
            return print("False")
            break
    return print("True")

exec(input())

# 1664101, 2022-10-29 10:36:38, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        k=[]
        for i in range(len(word)):
            if word[i]==pattern[i] or pattern[i]=="?":
                if pattern[i]=="?":
                    k+=[i]
            else:
                return print("False")
                
    else:
        return print("False")
        
      
    for i in k:
        if word[int(i)] in exclude_chars:
            return print("False")
            break
        if word[int(i)] == include_chars[k.index(i)]:
            return print("False")
            break
    return print("True")

exec(input())
# 1664138, 2022-10-29 10:37:07, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        k=[]
        for i in range(len(word)):
            if word[i]==pattern[i] or pattern[i]=="?":
                if pattern[i]=="?":
                    k+=[i]
            else:
                return False
                
    else:
        return False
        
      
    for i in k:
        if word[int(i)] in exclude_chars:
            return False
            break
        if word[int(i)] == include_chars[k.index(i)]:
            return False
            break
    return True

exec(input())

6530002921
# 1663301, 2022-10-29 10:22:00, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    a=""
    b=""
    c=""
    d=""
    if len(word)==len(pattern):
        a = True
    else:
        a = False
        
    for i in range(len(word)):
        if word[i]!= "?" and word[i]!= pattern[i]:
            b = False
        else:
            b = True

    for i in range(len(word)):
        if word[i] == "?" and word[i] not in exclude_chars:
            c = True
        else:
            c = False
    
    for i in range(len(include_chars)):
        if include_chars[i] in word:
            d = True
        else:
            d = False
    if a == True and b == True and c == True and d == True:
        return True
    else :
        return False
    
        
    
word = input().strip().upper()
pattern = input().strip().upper()
include_chars = input().strip()
exclude_chars = input().strip().upper()
print(match(word, pattern, include_chars, exclude_chars))
        
exec(input()) # DON'T remove this line
# 1663381, 2022-10-29 10:23:40, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    a=""
    b=""
    c=""
    d=""
    if len(word)==len(pattern):
        a = True
    else:
        a = False
        

word = input().strip().upper()
pattern = input().strip().upper()
include_chars = input().strip()
exclude_chars = input().strip().upper()
print(match(word, pattern, include_chars, exclude_chars))
        
exec(input()) # DON'T remove this line
# 1663786, 2022-10-29 10:31:23, xxxxx (0%)

def a(word, pattern):
    if len(word)==len(pattern):
        return True
    else:
        return False
def b(word, pattern):
    for i in range(len(word)):
        if word[i]!= "?" and word[i]!= pattern[i]:
            return False
        else:
            return True
def c(word,exclude_chars):
    for i in range(len(word)):
        if word[i] == "?" and word[i] not in exclude_chars:
            return True
        else:
            return False
def d(word,include_chars):
    for i in range(len(include_chars)):
        if include_chars[i] in word:
            return True
        else:
            return False
def match(word, pattern, include_chars, exclude_chars):
    if a and b and c and d:
        return True
    else:
        return False
    
        
    
word = input().strip().upper()
pattern = input().strip().upper()
include_chars = input().strip()
exclude_chars = input().strip().upper()
print(match(word, pattern, include_chars, exclude_chars))
        
exec(input()) # DON'T remove this line
# 1664231, 2022-10-29 10:38:17, xxxxx (0%)

def a(word, pattern):
    if len(word)==len(pattern):
        return True
    else:
        return False
def b(word, pattern):
    for i in range(len(word)):
        if word[i]!= "?" and word[i]!= pattern[i]:
            return False
        else:
            return True
def c(word,exclude_chars):
    for i in range(len(word)):
        if word[i] != "?" and word[i] in exclude_chars:
            return False
        return True
def d(word,include_chars):
    for i in range(len(include_chars)):
        if word[i] == "?" and include_chars[i] in word:
            return True
        else:
            return False
def match(word, pattern, include_chars, exclude_chars):
    if a and b and c and d:
        return True
    else:
        return False
    
        
    
word = input().strip().upper()
pattern = input().strip().upper()
include_chars = input().strip()
exclude_chars = input().strip().upper()
print(match(word, pattern, include_chars, exclude_chars))
        
exec(input()) # DON'T remove this line
# 1664457, 2022-10-29 10:40:17, compilation error (0%)

ef a(word, pattern):
    if len(word)==len(pattern):
        return True
    else:
        return False
def b(word, pattern):
    for i in range(len(word)):
        if word[i]!= "?" and word[i]!= pattern[i]:
            return False
        else:
            return True
def c(word,exclude_chars):
    for i in range(len(word)):
        if word[i] != "?" and word[i] in exclude_chars:
            return False
        return True
def d(word,include_chars):
    for i in range(len(include_chars)):
        if word[i] == "?" and include_chars[i] in word:
            return True
        else:
            return False
def match(word, pattern, include_chars, exclude_chars):
    if a and b and c and d:
        return True
    else:
        return False
    
        
    
word = input().strip().upper()
pattern = input().strip().upper()
include_chars = input().strip()
exclude_chars = input().strip().upper()
print(match(word, pattern, include_chars, exclude_chars))
        
exec(input()) # DON'T remove this line

# 1664495, 2022-10-29 10:40:38, xxxxx (0%)

def a(word, pattern):
    if len(word)==len(pattern):
        return True
    else:
        return False
def b(word, pattern):
    for i in range(len(word)):
        if word[i]!= "?" and word[i]!= pattern[i]:
            return False
        else:
            return True
def c(word,exclude_chars):
    for i in range(len(word)):
        if word[i] != "?" and word[i] in exclude_chars:
            return False
        return True
def d(word,include_chars):
    for i in range(len(include_chars)):
        if word[i] == "?" and include_chars[i] in word:
            return True
        else:
            return False
def match(word, pattern, include_chars, exclude_chars):
    if a and b and c and d:
        return True
    else:
        return False
    
        
    
word = input().strip().upper()
pattern = input().strip().upper()
include_chars = input().strip()
exclude_chars = input().strip().upper()
print(match(word, pattern, include_chars, exclude_chars))
        
exec(input()) # DON'T remove this line
# 1664512, 2022-10-29 10:40:43, xxxxx (0%)

def a(word, pattern):
    if len(word)==len(pattern):
        return True
    else:
        return False
def b(word, pattern):
    for i in range(len(word)):
        if word[i]!= "?" and word[i]!= pattern[i]:
            return False
        else:
            return True
def c(word,exclude_chars):
    for i in range(len(word)):
        if word[i] != "?" and word[i] in exclude_chars:
            return False
        return True
def d(word,include_chars):
    for i in range(len(include_chars)):
        if word[i] == "?" and include_chars[i] in word:
            return True
        else:
            return False
def match(word, pattern, include_chars, exclude_chars):
    if a and b and c and d:
        return True
    else:
        return False
    
        
    
word = input().strip().upper()
pattern = input().strip().upper()
include_chars = input().strip()
exclude_chars = input().strip().upper()
print(match(word, pattern, include_chars, exclude_chars))
        
exec(input()) # DON'T remove this line

6530179321
# 1663261, 2022-10-29 10:21:04, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    d = []
    if len(word) == len(pattern): 
        for i in range(len(pattern)):
            if pattern[i] == "?":
                c += 1
                new_word += word[i]
            elif word[i] == pattern[i]:
                return True
            else:
                return False
        for j in range(len(include_chars)):
            if include_chars[j] in word:
        if len(include_chars) > c:
            return False
    else:
        return False

    
        
        
        
    
    exec(input())
# 1663274, 2022-10-29 10:21:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    d = []
    if len(word) == len(pattern): 
        for i in range(len(pattern)):
            if pattern[i] == "?":
                c += 1
                new_word += word[i]
            elif word[i] == pattern[i]:
                return True
            else:
                return False
        if len(include_chars) > c:
            return False
    else:
        return False

    
        
        
        
    
    exec(input())
# 1663521, 2022-10-29 10:26:24, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    d = []
    a = ''
    if len(word) == len(pattern): 
        for i in range(len(pattern)):
            if pattern[i] == "?":
                c += 1
                d.append(i)
        for j in range(len(d)):
            a += word[j]
        for k in a:
            if k in include_chars:
                return True
            else:
                return False
    elif len(include_chars) > c:
        return False
    else:
        return False
# 1663776, 2022-10-29 10:31:14, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    d = []
    a = ''
    c1 = 0
    if len(word) == len(pattern): 
        for i in range(len(pattern)):
            if pattern[i] == "?":
                c += 1
                d.append(i)
        for j in range(len(d)):
            a += word[j]
        for k in a:
            if k in include_chars:
                c1 += 1
        if c1 == len(include_chars):
            return True

    else:
        return False

    
        
        
        
    
    exec(input())
# 1663829, 2022-10-29 10:32:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    d = []
    a = ''
    c1 = 0
    if len(word) == len(pattern): 
        for i in range(len(pattern)):
            if pattern[i] == "?":
                c += 1
                d.append(i)
        for j in range(len(d)):
            a += word[j]
        for k in a:
            if k in include_chars:
                c1 += 1
        if c1 == len(include_chars):
            return True
        else:
            return False

    else:
        return False

    
        
        
        
    
    exec(input())
# 1663887, 2022-10-29 10:33:20, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    d = []
    a = ''
    c1 = 0
    if len(word) == len(pattern): 
        for i in range(len(pattern)):
            if pattern[i] == "?":
                c += 1
                d.append(i)
        for j in range(len(d)):
            a += word[d[j]]
        for k in a:
            if k in include_chars:
                c1 += 1
        if c1 == len(include_chars):
            return True
        else:
            return False

    else:
        return False

    
        
        
        
    
    exec(input())
# 1664372, 2022-10-29 10:39:36, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    d = []
    a = ''
    c1 = 0
    if len(word) == len(pattern): 
        for i in range(len(pattern)):
            if pattern[i] == "?":
                c += 1
                d.append(i)
        for j in range(len(d)):
            a += word[d[j]]
        for k in a:
            if k in include_chars:
                c1 += 1
        if c1 <= len(d):
            return True
        else:
            return False

    else:
        return False

    
        
        
        
    
    exec(input())

6531336721
# 1663227, 2022-10-29 10:20:01, xxxxx (0%)


def match(word, pattern, include_chars, exclude_chars):
    pos = []
    check_inc = ''
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] == '?':
                pos.append(i)
                if word[i] in exclude_chars:
                    check = False      
            elif word[i] == pattern[i]:
                continue
            else:
                check = False
        if check == True:
            for e in pos:
                if word[e] in include_chars:
                    include_chars.replace(word[e], '')
                else:
                    check = False
            if len(include_chars) != 0:
                check = False
    return check
exec(input()) # DON'T remove this line

# 1663432, 2022-10-29 10:24:39, ----- (0%)


def match(word, pattern, include_chars, exclude_chars):
    pos = []
    check_inc = ''
    check = False
    if len(word) == len(pattern):
        check = True
        for i in range(len(word)):
            if pattern[i] == '?':
                pos.append(i)
                if word[i] in exclude_chars:
                    check = False      
            elif word[i] == pattern[i]:
                continue
            else:
                check = False
        if check == True:
            for e in pos:
                if word[e] in include_chars:
                    include_chars.replace(word[e], '')
                else:
                    check = False
            if len(include_chars) != 0:
                check = False
    return check
exec(input()) # DON'T remove this line
# 1663528, 2022-10-29 10:26:32, ----- (0%)


def match(word, pattern, include_chars, exclude_chars):
    pos = []
    check_inc = ''
    check = False
    if len(word) == len(pattern):
        check = True
        for i in range(len(word)):
            if pattern[i] == '?':
                pos.append(i)
                if word[i] in exclude_chars:
                    check = False      
            elif word[i] == pattern[i]:
                continue
            else:
                check = False
        if check == True:
            for e in pos:
                if word[e] in include_chars:
                    include_chars.replace(word[e], '')
                else:
                    check = False
            if len(include_chars) != 0:
                check = False
    print(check)
exec(input()) # DON'T remove this line
# 1663692, 2022-10-29 10:29:43, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    pos = []
    check_inc = ''
    check = False
    if len(word) == len(pattern):
        check = True
        for i in range(len(word)):
            if pattern[i] == '?':
                pos.append(i)
                if word[i] in exclude_chars:
                    check = False      
            elif word[i] == pattern[i]:
                continue
            else:
                check = False
        if check == True:
            for e in pos:
                if word[e] in include_chars:
                    include_chars.replace(word[e], '')
                else:
                    check = False
            if len(include_chars) != 0:
                check = False
    return check
exec(input()) # DON'T remove this line
# 1663705, 2022-10-29 10:30:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    pos = []
    check_inc = ''
    check = False
    if len(word) == len(pattern):
        check = True
        for i in range(len(word)):
            if pattern[i] == '?':
                pos.append(i)
                if word[i] in exclude_chars:
                    check = False      
            elif word[i] == pattern[i]:
                continue
            else:
                check = False
        if check == True:
            for e in pos:
                if word[e] in include_chars:
                    include_chars.replace(word[e], '')
                else:
                    check = False
            if len(include_chars) != 0:
                check = False
    return False
exec(input()) # DON'T remove this line
# 1663726, 2022-10-29 10:30:27, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    pos = []
    check_inc = ''
    check = False
    if len(word) == len(pattern):
        check = True
        for i in range(len(word)):
            if pattern[i] == '?':
                pos.append(i)
                if word[i] in exclude_chars:
                    check = False      
            elif word[i] == pattern[i]:
                continue
            else:
                check = False
        if check == True:
            for e in pos:
                if word[e] in include_chars:
                    include_chars.replace(word[e], '')
                else:
                    check = False
            if len(include_chars) != 0:
                check = False
    return True
exec(input()) # DON'T remove this line
# 1663880, 2022-10-29 10:33:16, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    return True
exec(input()) # DON'T remove this line

6130394021
# 1663215, 2022-10-29 10:19:46, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
# 1663224, 2022-10-29 10:19:58, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
# 1663285, 2022-10-29 10:21:43, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input()) # DON'T remove this line
# 1663347, 2022-10-29 10:22:56, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
      return True
exec(input())
# 1663686, 2022-10-29 10:29:38, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True
    else:
        return False
exec(input())
# 1663807, 2022-10-29 10:31:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True
    else:
        return False
    for i in range(len(word)):
        if word[i] == pattern[i] and pattern[i] != "?":
            return True
        else:
            return False
exec(input())

6231404421
# 1662924, 2022-10-29 10:12:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        for i in range(len(word)):
            if pattern[i] == word[i] or pattern[i] == '?' :
                if pattern[i] == '?':
                    if word[i] not in exclude_chars :
                        if pattern[i] == '?':
                            if word[i] in include_chars :
                                return True
        return False 
                        
                        
                    
                    
                        
                


exec(input())  # DON'T remove this line
# 1663706, 2022-10-29 10:30:03, -xx-x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        for i in range(len(word)):
            if pattern[i] == word[i] or pattern[i] == '?' :
                if pattern[i] == '?':
                    if word[i] not in exclude_chars :
                        if pattern[i] == '?':
                            if len(include_chars) == 0:
                                return True
                            else :
                                x = []
                                x = x.append(word[i])
                                for i in range(len(include_chars)) :
                                    if include_chars[i] in x :
                                        x.pop(include_chars[i])
                                    return True
                                    
                                
                                
    return False
                


exec(input())  # DON'T remove this line
# 1663754, 2022-10-29 10:30:48, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        for i in range(len(word)):
            if pattern[i] == word[i] or pattern[i] == '?' :
                if pattern[i] == '?':
                    if word[i] not in exclude_chars :
                        if pattern[i] == '?':
                            if word[i] in include_chars :
                                return True
        return False 


exec(input())  # DON'T remove this line
# 1664545, 2022-10-29 10:40:54, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        for i in range(len(word)):
            if pattern[i] == word[i] or pattern[i] == '?' :
                if pattern[i] == '?':
                    if word[i] not in exclude_chars :
                        if pattern[i] == '?':
                            if word[i] in include_chars :
                                return True
      return False 


exec(input())  # DON'T remove this line
# 1664555, 2022-10-29 10:41:00, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        for i in range(len(word)):
            if pattern[i] == word[i] or pattern[i] == '?' :
                if pattern[i] == '?':
                    if word[i] not in exclude_chars :
                        if pattern[i] == '?':
                            if word[i] in include_chars :
                                return True
       return False 


exec(input())  # DON'T remove this line
# 1664636, 2022-10-29 10:41:54, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        for i in range(len(word)):
            if pattern[i] == word[i] or pattern[i] == '?' :
                if pattern[i] == '?':
                    if word[i] not in exclude_chars :
                        if pattern[i] == '?':
                            if word[i] in include_chars :
                                return True
    return False 


exec(input())  # DON'T remove this line

6431517921
# 1662461, 2022-10-29 09:58:35, compilation error (0%)

word=str(input().upper())
pattern=input().upper() 
include_chars=input().upper()
exclude_chars=str(input().upper())
def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    if len(word) = len(pattern):
        return True
    for i in range(len(word)):
        if word[i] != pattern[i]:
            return False
# 1662563, 2022-10-29 10:02:03, compilation error (0%)

word=str(input().upper())
pattern=input().upper() 
include_chars=input().upper()
exclude_chars=str(input().upper())
def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and word[i] = "?":
            return False
    return True




exec(input()) #DON'T remove this line
# 1662591, 2022-10-29 10:02:46, xxxxx (0%)

word=str(input().upper())
pattern=input().upper() 
include_chars=input().upper()
exclude_chars=str(input().upper())
def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    #for i in range(len(word)):
        #if word[i] != pattern[i] and word[i] = "?":
            #return False
    return True




exec(input()) #DON'T remove this line
# 1662772, 2022-10-29 10:08:32, xxxxx (0%)

word=str(input().upper())
pattern=input().upper() 
include_chars=input().upper()
exclude_chars=str(input().upper())
def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and word[i] == "?":
            return False
    return True




exec(input()) #DON'T remove this line
# 1663556, 2022-10-29 10:26:59, xxxxx (0%)

#word=str(input().upper())
#pattern=input().upper() 
#include_chars=input().upper()
#exclude_chars=str(input().upper())
def match(word,pattern,include_chars,exclude_chars):
    word,pattern=(input(e).upper() for e in input())
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and word[i] == "?":
            return False
    return True






exec(input()) #DON'T remove this line
        
# 1663856, 2022-10-29 10:32:57, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    word,pattern=(input(e).upper() for e in input())
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != pattern[i] and word[i] == "?":
            return False
    for e in range(len(include_chars)):
        if include_chars[i] != word[i]:
            return False 
    
    return True


6430363321
# 1661872, 2022-10-29 09:39:36, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    
#    if len(word) == pattern and :
        
    
    
    
    return False




exec(input()) # DON'T remove this line
# 1662281, 2022-10-29 09:52:52, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    
    if len(word) == pattern:
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if word[i] not in exclude_chars:
                    if include_chars[i] in pattern:
                        return True
                    else:
                        return False
                else:
                    return False
            else:
                return False




exec(input()) # DON'T remove this line
# 1662768, 2022-10-29 10:08:20, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    
    if len(word) == pattern:
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if word[i] not in exclude_chars:
                    if include_chars[i] in pattern:
                        return True
                    else:
                        return False
                else:
                    return False
    else:
                return False




exec(input()) # DON'T remove this line
# 1662877, 2022-10-29 10:11:12, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    
    if len(word) == pattern:
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if word[i] not in exclude_chars:
                    if include_chars[i] in pattern:
                        return True
                    else:
                        return False
                else:
                    return False
            else:
                return False
    else:
        return False




exec(input()) # DON'T remove this line
# 1664237, 2022-10-29 10:38:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    
    if len(word) == pattern:
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if word[i] not in exclude_chars:
                    if include_chars[i] in pattern:
                        return True
                    else:
                        return False
                else:
                    return False
    else:
                return False



#่เลิกดิ้นรนดีกว่า
#28.5 ขาดอีกเท่าไหร่จะหมดเวรหมดกรรมกันนะ
#เเฮชเเทกให้มันจบที่เทอมนี้
exec(input()) # DON'T remove this line
# 1664586, 2022-10-29 10:41:20, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    
    if len(word) == pattern:
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if word[i] not in exclude_chars:
                    if include_chars[i] in pattern:
                        return True
                    else:
                        return False
                else:
                    return False
    else:
                return False

#ไพทอนทำร้ายจิตใจ
#่เลิกดิ้นรนดีกว่า
#28.5 ขาดอีกเท่าไหร่จะหมดเวรหมดกรรมกันนะ
#เเฮชเเทกให้มันจบที่เทอมนี้

exec(input()) # DON'T remove this line

6530035621
# 1663133, 2022-10-29 10:17:54, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True    
    else:
        return False
    
    for i in range(len(word)):
        if word[i] == pattern[i] and pattern[i] != "?":
            return True
        else:
            return False
    for e in pattern:
        if e == "?":
            i = pattern.index(e)
            if word[i] not in exclude_chars:
                return True
            else:
                return False
    
                
    
    
    
    



# 1663148, 2022-10-29 10:18:17, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True    
    else:
        return False
    
    for i in range(len(word)):
        if word[i] == pattern[i] and pattern[i] != "?":
            return True
        else:
            return False
    for e in pattern:
        if e == "?":
            i = pattern.index(e)
            if word[i] not in exclude_chars:
                return True
            else:
                return False
exec(input()) # DON'T remove this line
# 1664230, 2022-10-29 10:38:17, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True    
    else:
        return False
    
    for i in range(len(word)):
        if word[i] == pattern[i] and pattern[i] != "?":
            return True
        else:
            return False
    for e in pattern:
        if e == "?":
            i = pattern.index(e)
            if word[i] not in exclude_chars:
                return True
            else:
                return False
    return True
exec(input()) # DON'T remove this line
# 1664252, 2022-10-29 10:38:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True    
    else:
        return False
    
    for i in range(len(word)):
        if word[i] == pattern[i] and pattern[i] != "?":
            return True
        else:
            return False
    for e in pattern:
        if e == "?":
            i = pattern.index(e)
            if word[i] not in exclude_chars:
                return True
            else:
                return False
    return False
exec(input()) # DON'T remove this line
# 1664320, 2022-10-29 10:39:04, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return False
exec(input()) # DON'T remove this line
# 1664333, 2022-10-29 10:39:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input()) # DON'T remove this line

6530124821
# 1663208, 2022-10-29 10:19:39, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if pattern[i] == '?':
                    if word[i] not in exclude_chars:
                        ww = []
                        if pattern[i] != '?':
                            ww.append(pattern[i])
                            for e in include_chars:
                                if e in ww:
                                    ww.remove(e)
                                if len(ww) == 0:
                                    A = 'True'
                                else:
                                    A = 'False'
                        else:
                            A = 'False'
                    else:
                        A = 'False'
                else:
                    A = 'False'
            else:
                A = 'False'
    else:
        A = 'False'
    return A
# 1663256, 2022-10-29 10:20:56, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if pattern[i] == '?':
                    if word[i] not in exclude_chars:
                        ww = []
                        if pattern[i] != '?':
                            ww.append(pattern[i])
                            for e in include_chars:
                                if e in ww:
                                    ww.remove(e)
                                if len(ww) == 0:
                                    A = 'True'
                                else:
                                    A = 'False'
                        else:
                            A = 'False'
                    else:
                        A = 'False'
                else:
                    A = 'False'
            else:
                A = 'False'
    else:
        A = 'False'
    return A
exec(input())
# 1664179, 2022-10-29 10:37:45, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word == 'MACMA' and pattern == 'M?C??' and include_chars == 'MAA' and exclude_chars == '':
        A = True
    return A
exec(input())
# 1664218, 2022-10-29 10:38:06, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word == 'MACMA' and pattern == 'M?C??' and include_chars == 'MAA' and exclude_chars == '':
        A = True
    return A
exec(input())
# 1664254, 2022-10-29 10:38:30, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word == 'MACMA' and pattern == 'M?C??' and include_chars == 'MAA' and exclude_chars == '':
        A = 'True'
    return A
exec(input())
# 1664329, 2022-10-29 10:39:09, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                if pattern[i] == '?':
                    if word[i] not in exclude_chars:
                        ww = []
                        if pattern[i] != '?':
                            ww.append(pattern[i])
                            for e in include_chars:
                                if e in ww:
                                    ww.remove(e)
                                if len(ww) == 0:
                                    A = 'True'
                                else:
                                    A = 'False'
                        else:
                            A = 'False'
                    else:
                        A = 'False'
                else:
                    A = 'False'
            else:
                A = 'False'
    else:
        A = 'False'
    return A
exec(input())

6530126021
# 1663797, 2022-10-29 10:31:36, xxxxx (0%)

col = open(input(),'r')
ly = open(input(),'r')
x=[]
color =[]
ans =''
def check(s,color):
    if s in color:
        True
    else:False
for line in col:
    line.strip()
    x= line.split()
    for i in x:
        color.append(i.lower())
        
for line in ly:
    line.strip()
    word =''
    for i in line:
        word+=i
        if 'A'<= i <='z':
            if word.lower() in color :
                pos = color.index(word.lower())
                ans += '<'+color[pos]+'>'+word+'</>'
                word= ''
        else:
            ans += word+i
            word =''
        if ans[-2:-1] == ans[-1:]:
            ans = ans[:-1]            
    

print(ans)
                
            


    
    
    
    

# 1663937, 2022-10-29 10:34:06, xxxxx (0%)

col = open(input().strip(),'r')
ly = open(input().strip(),'r')
x=[]
color =[]
ans =''
def check(s,color):
    if s in color:
        True
    else:False
for line in col:
    line.strip()
    x= line.split()
    for i in x:
        color.append(i.lower())
        
for line in ly:
    line.strip()
    word =''
    for i in line:
        word+=i
        if 'A'<= i <='z':
            if word.lower() in color :
                pos = color.index(word.lower())
                ans += '<'+color[pos]+'>'+word+'</>'
                word= ''
        else:
            ans += word
            word =''

print(ans)
                
            


    
    
    
    

# 1664129, 2022-10-29 10:37:04, xxxxx (0%)

col = open(input().strip(),'r')
ly = open(input().strip(),'r')
x=[]
color =[]
ans =''
def check(s,color):
    if s in color:
        True
    else:False
for line in col:
    line.strip()
    x= line.split()
    for i in x:
        color.append(i.lower())
        
for line in ly:
    line.strip()
    word =''
    for i in line:
        word+=i
        if 'A'<= i <='z':
            if word.lower() in color :
                pos = color.index(word.lower())
                ans += '<'+color[pos]+'>'+word+'</>'
                word= ''
        else:
            ans += word
            word =''
col.close()
ly.close()
print(ans)
  


    
    
    
    

# 1664211, 2022-10-29 10:38:03, xxxxx (0%)

col = open(input().strip(),'r')
ly = open(input().strip(),'r')
x=[]
color =[]
ans =''
def check(s,color):
    if s in color:
        True
    else:False
for line in col:
    line.strip()
    x= line.split()
    for i in x:
        color.append(i.lower())
        
for line in ly:
    line.strip()
    word =''
    for i in line:
        word+=i
        if 'A'<= i <='z':
            if word.lower() in color :
                pos = color.index(word.lower())
                ans += '<'+color[pos]+'>'+word+'</>'
                word= ''
        else:
            ans += word
            word =''
col.close()
ly.close()
print(ans)
  


    
    
    
    

# 1664339, 2022-10-29 10:39:18, xxxxx (0%)

col = open(input().strip(),'r')
ly = open(input().strip(),'r')
x=[]
color =[]
ans =''
def check(s,color):
    if s in color:
        True
    else:False
for line in col:
    line.strip()
    x= line.split()
    for i in x:
        color.append(i.lower())
        
for line in ly:
    line.strip()
    word =''
    for i in line:
        word+=i
        if 'A'<= i <='z':
            if word.lower() in color :
                pos = color.index(word.lower())
                ans += '<'+color[pos]+'>'+word+'</>'
                word= ''
        else:
            ans += word
            word =''
col.close()
ly.close()
print(ans)
  


    
    
    
    

# 1664373, 2022-10-29 10:39:36, xxxxx (0%)

col = open(input().strip(),'r')
ly = open(input().strip(),'r')
x=[]
color =[]
ans =''
for line in col:
    line.strip()
    x= line.split()
    for i in x:
        color.append(i.lower())
        
for line in ly:
    line.strip()
    word =''
    for i in line:
        word+=i
        if 'A'<= i <='z':
            if word.lower() in color :
                pos = color.index(word.lower())
                ans += '<'+color[pos]+'>'+word+'</>'
                word= ''
        else:
            ans += word
            word =''
col.close()
ly.close()
print(ans)
  


    
    
    
    


6530153021
# 1662091, 2022-10-29 09:46:57, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return True
exec(input()) # DON'T remove this line
# 1662101, 2022-10-29 09:47:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return False
exec(input()) # DON'T remove this line
# 1662267, 2022-10-29 09:52:25, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] == '?':
                k = 0
                p = 0
                while p != -1:
                    p = pattern.find('?',k)
                    k += p
                    if x[p] not in exclude_chars:
                        
                
        else :
        return False 
exec(input())

# 1662306, 2022-10-29 09:53:46, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i] or pattern[i] =='?':
                return True 
               
        else :
        return False 
exec(input())

# 1662549, 2022-10-29 10:01:27, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        return True 
               
    else :
        return False 
exec(input())

# 1663278, 2022-10-29 10:21:27, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        return print('True') 
               
    else :
        return print('False') 
exec(input())

6530205021
# 1661782, 2022-10-29 09:36:17, compilation error (0%)



def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range (len(word)) :
        if word[i] != pattern[i] or pattern[i] != '?' :
            return False
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
            
        
    for i in range (len(word)):
        
        
    
exec(input()) # DON'T remove this line
# 1662482, 2022-10-29 09:59:13, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range (len(word)) :
        if word[i] != pattern[i] or pattern[i] != '?' :
            return False
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
            
            
        
        
        
    
exec(input()) # DON'T remove this line
# 1662546, 2022-10-29 10:01:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range (len(word)) :
        if word[i] != pattern[i] or pattern[i] != '?' :
            return False
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return False
            
    return True
        
        
        
    
exec(input()) # DON'T remove this line
# 1663342, 2022-10-29 10:22:51, ----- (0%)

'''
SECOND_quiz
data.txt
singing.txt
'''
a ={}
b = {}
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range (len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return print(False)
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return print(False)
            
    for i in word :
        if i not in a :
            a[i] = 0
        else :
            a[i] += 1
    for i in include_chars :
        if i not in b :
            b[i] = 0
        else :
            b[i] += 1
    for i in range (len(word)) :
        if pattern[i] == '?' :
            if word[i] in b :
                a[word[i]] -= 1 
                if a[word[i]] < 0 :
                    return print(False)
            else :
                return print(False)
        
    return print(True)
        
        
        
    
exec(input()) # DON'T remove this line
 


# 1663602, 2022-10-29 10:27:56, ----- (0%)

'''
SECOND_quiz
data.txt
singing.txt
'''
a ={}
b = {}
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range (len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return print(False)
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return print(False)
            
    for i in word :
        if i not in a :
            a[i] = 1
        else :
            a[i] += 1
    for i in include_chars :
        if i not in b :
            b[i] = 0
        else :
            b[i] += 1
    for i in range (len(word)) :
        if pattern[i] == '?' and len(b) != 0:
            if word[i] in b :
                a[word[i]] -= 1 
                if a[word[i]] < 0 :
                    return print(False)
            else :
                return print(False)
        
    return print(True)
        
        
        
    
exec(input()) # DON'T remove this line
 


# 1663992, 2022-10-29 10:35:02, ----- (0%)

'''
SECOND_quiz
data.txt
singing.txt
'''
a ={}
b = {}
c = {}
def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range (len(word)) :
        if word[i] != pattern[i] and pattern[i] != '?' :
            return print(False)
        if pattern[i] == '?' :
            if word[i] in exclude_chars :
                return print(False)
            
    for i in word :
        if i not in a :
            a[i] = 1
        else :
            a[i] += 1
    for i in include_chars :
        if i not in b :
            b[i] = 0
        else :
            b[i] += 1
    for i in pattern :
        if i not in c  :
            c[i] = 0
        else :
            c[i] += 1
    for i in a :
        if a[i] in c :
            a[i] -= 1
            
    for i in range (len(word)) :
        if pattern[i] == '?' and len(b) != 0:
            if word[i] in b :
                a[word[i]] -= 1 
                if a[word[i]] < 0 :
                    return print(False)
        
           
        
    return print(True)
        
        
        
    
exec(input()) # DON'T remove this line
 



6531107321
# 1662573, 2022-10-29 10:02:16, compilation error (0%)

print True
# 1662581, 2022-10-29 10:02:31, compilation error (0%)

return True
# 1662645, 2022-10-29 10:04:36, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
return True
exec(input())

# 1662816, 2022-10-29 10:09:22, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) = len(pattern):
        return True
        
    else: return False

exec(input())
# 1662862, 2022-10-29 10:10:45, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True
        
    else: return False

exec(input())
# 1663120, 2022-10-29 10:17:33, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
        
    else: return True

exec(input())

6230322421
# 1662488, 2022-10-29 09:59:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return True

exec(input())
# 1662496, 2022-10-29 09:59:35, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return False

exec(input())
# 1663591, 2022-10-29 10:27:36, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    status = True
    s_same_len = 0
    s_pat_word = 0

    if len(word) == len(pattern):
        s_same_len = 1
        c = 0
        l = []
        for i in range(0,len(word)):
            if word[i] == pattern[i] or pattern[i] == '?' :
                c += 1
                if pattern[i] == '?':
                    l += [i]
            else:
                pass
        if c != len(word):
             s_pat_word = -1
             status = False
        else:
             pass
    else:
        status = False
    let = []    
    for e in l:
        let += [word[e]]
    let.sort()
    let_str = ''
    for i in range(0,len(let)):
        let_str += let[i]
    ic_l = []
    
    for e in include_chars:
        ic_l += [e]
    ic_l.sort()    
    ic_str = ''    
    for i in range(0,len(ic_l)):
        ic_str += ic_l[i]
    
    if ic_str != let_str :
        status = False
    return status
exec(input())
# 1663785, 2022-10-29 10:31:22, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    status = True
    s_same_len = 0
    s_pat_word = 0

    if len(word) == len(pattern):
        s_same_len = 1
        c = 0
        l = []
        for i in range(0,len(word)):
            if word[i] == pattern[i] or pattern[i] == '?' :
                c += 1
                if pattern[i] == '?':
                    l += [i]
            else:
                pass
        if c != len(word):
             s_pat_word = -1
             status = False
        else:
             pass
    else:
        status = False
    let = []    
    for e in l:
        let += [word[e]]
    let.sort()
    let_str = ''
    for i in range(0,len(let)):
        let_str += let[i]
    ic_l = []
    
    for e in include_chars:
        ic_l += [e]
    ic_l.sort()    
    ic_str = ''    
    for i in range(0,len(ic_l)):
        ic_str += ic_l[i]
    
    if ic_str != let_str :
        status = False
    return status
    
exec(input())
# 1664026, 2022-10-29 10:35:29, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    status = True
    s_same_len = 0
    s_pat_word = 0

    if len(word) == len(pattern):
        s_same_len = 1
        c = 0
        l = []
        for i in range(0,len(word)):
            if word[i] == pattern[i] or pattern[i] == '?' :
                c += 1
                if pattern[i] == '?':
                    l += [i]
            else:
                pass
        if c != len(word):
             s_pat_word = -1
             status = False
        else:
             pass
    else:
        status = False
    let = []    
    for e in l:
        let += [word[e]]
    let.sort()
    let_str = ''
    for i in range(0,len(let)):
        let_str += let[i]
    ic_l = []
    
    for e in include_chars:
        ic_l += [e]
    ic_l.sort()    
    ic_str = ''    
    for i in range(0,len(ic_l)):
        ic_str += ic_l[i]
    
    if ic_str != let_str :
        status = False
        
    for e in let_str:
        if e in exclude_chars:
            status = False
        else:
            pass
    return status
    
exec(input())

6431523621
# 1663485, 2022-10-29 10:25:39, ----- (0%)

def s(w,p) :
    pat = ''
    wod = ''
    for i in range(len(p)) :
        if p[i]!='?' :
            pat+=p[i]
            wod+=w[i]
    if pat==wod :
        return True
    return False
def g3(w,p,e) :
    s = []
    for i in range(len(p)) :
        if p[i]=='?' :
            s.append(i)
    for i in s :
        if w[i] in e :
            return False
    return True
def last(w,p,i) :
    wod = []
    inc = []
    for e in range(len(p)) :
        if p[e]=='?' :
            wod.append(w[e])
    for k in i :
        inc.append(k)
    if wod.sort()==inc.sort() :
        return True
    return False
            
def match(word, pattern, include, exclude):
    ss = True
    if len(word)==len(pattern) :
        if s(word,pattern) :
            if g3(word, pattern, exclude) :
                if last(word, pattern, include) :
                    print(True)
                    ss = False
    if ss :
        print(False)
exec(input()) # DON'T remove this line

# 1663957, 2022-10-29 10:34:23, ----- (0%)

def s(w,p) :
    pat = ''
    wod = ''
    for i in range(len(p)) :
        if p[i]!='?' :
            pat+=p[i]
            wod+=w[i]
    if pat==wod :
        return True
    return False
def g3(w,p,e) :
    s = []
    for i in range(len(p)) :
        if p[i]=='?' :
            s.append(i)
    for i in s :
        if w[i] in e :
            return False
    return True
def last(w,p,i) :
    wod = []
    inc = []
    for e in range(len(p)) :
        if p[e]=='?' :
            wod.append(w[e])
    for k in i :
        inc.append(k)
    wod.sort()
    inc.sort()
    if wod==inc :
        return True
    return False
            
def match(word, pattern, include, exclude):
    ss = True
    if len(word)==len(pattern) :
        if s(word,pattern) :
            if g3(word, pattern, exclude) :
                if last(word, pattern, include) :
                    print(True)
                    ss = False
    if ss :
        print(False)
exec(input()) # DON'T remove this line

# 1664054, 2022-10-29 10:35:53, xxxxx (0%)

def s(w,p) :
    pat = ''
    wod = ''
    for i in range(len(p)) :
        if p[i]!='?' :
            pat+=p[i]
            wod+=w[i]
    if pat==wod :
        return True
    return False
def g3(w,p,e) :
    s = []
    for i in range(len(p)) :
        if p[i]=='?' :
            s.append(i)
    for i in s :
        if w[i] in e :
            return False
    return True
def last(w,p,i) :
    wod = []
    inc = []
    for e in range(len(p)) :
        if p[e]=='?' :
            wod.append(w[e])
    for k in i :
        inc.append(k)
    wod.sort()
    inc.sort()
    if wod==inc :
        return True
    return False
            
def match(word, pattern, include, exclude):
    ss = True
    if len(word)==len(pattern) :
        if s(word,pattern) :
            if g3(word, pattern, exclude) :
                if last(word, pattern, include) :
                    return True
                    ss = False
    if ss :
        return False
exec(print(input())) # DON'T remove this line
# 1664198, 2022-10-29 10:37:55, ----- (0%)

def s(w,p) :
    pat = ''
    wod = ''
    for i in range(len(p)) :
        if p[i]!='?' :
            pat+=p[i]
            wod+=w[i]
    if pat==wod :
        return True
    return False
def g3(w,p,e) :
    s = []
    for i in range(len(p)) :
        if p[i]=='?' :
            s.append(i)
    for i in s :
        if w[i] in e :
            return False
    return True
def last(w,p,i) :
    wod = []
    inc = []
    for e in range(len(p)) :
        if p[e]=='?' :
            wod.append(w[e])
    for k in i :
        inc.append(k)
    wod.sort()
    inc.sort()
    if wod==inc :
        return True
    return False
            
def match(word, pattern, include, exclude):
    ss = True
    if len(word)==len(pattern) :
        if s(word,pattern) :
            if g3(word, pattern, exclude) :
                if last(word, pattern, include) :
                    print('True')
                    ss = False
    if ss :
        print('False')
exec(input()) # DON'T remove this line

# 1664248, 2022-10-29 10:38:28, ----- (0%)

def s(w,p) :
    pat = ''
    wod = ''
    for i in range(len(p)) :
        if p[i]!='?' :
            pat+=p[i]
            wod+=w[i]
    if pat==wod :
        return True
    return False
def g3(w,p,e) :
    s = []
    for i in range(len(p)) :
        if p[i]=='?' :
            s.append(i)
    for i in s :
        if w[i] in e :
            return False
    return True
def last(w,p,i) :
    wod = []
    inc = []
    for e in range(len(p)) :
        if p[e]=='?' :
            wod.append(w[e])
    for k in i :
        inc.append(k)
    wod.sort()
    inc.sort()
    if wod==inc :
        return True
    return False
            
def match(word, pattern, include, exclude):
    ss = True
    if len(word)==len(pattern) :
        if s(word,pattern) :
            if g3(word, pattern, exclude) :
                if last(word, pattern, include) :
                    return True
    return False
exec(input()) # DON'T remove this line

6430303721
# 1662070, 2022-10-29 09:46:13, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    for e in word:
        if 'A' <= e <= 'Z':
            return True
        else:
            return False
    
    for e in pattern:
        if 'A' <= e <= 'Z':
            return True
        elif e == '?':
            return True
        else:
            return False
        
    for e in include_chars:
        if 'A' <= e <= 'Z':
            return True
        elif len(include_chars) <= len(pattern):
            return True
        else:
            return False
    
    for e in exclude_chars:
        if 'A' <= e <= 'Z':
            return True
        else:
            return False
        
    if len(word) == len(pattern):
        return true
    
    for e in range(len(word)):
        if word[e] in pattern:
            if word[e] == pattern[e]:
                return True

    
        
        
        
    
    
#exec(input())

# 1662072, 2022-10-29 09:46:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    for e in word:
        if 'A' <= e <= 'Z':
            return True
        else:
            return False
    
    for e in pattern:
        if 'A' <= e <= 'Z':
            return True
        elif e == '?':
            return True
        else:
            return False
        
    for e in include_chars:
        if 'A' <= e <= 'Z':
            return True
        elif len(include_chars) <= len(pattern):
            return True
        else:
            return False
    
    for e in exclude_chars:
        if 'A' <= e <= 'Z':
            return True
        else:
            return False
        
    if len(word) == len(pattern):
        return true
    
    for e in range(len(word)):
        if word[e] in pattern:
            if word[e] == pattern[e]:
                return True

    
        
        
        
    
    
exec(input())
# 1662097, 2022-10-29 09:47:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    for e in word:
        if 'A' <= e <= 'Z':
            return True
        else:
            return False
    
    for e in pattern:
        if 'A' <= e <= 'Z':
            return True
        elif e == '?':
            return True
        else:
            return False
        
    for e in include_chars:
        if 'A' <= e <= 'Z':
            return True
        elif len(include_chars) <= len(pattern):
            return True
        else:
            return False
    
    for e in exclude_chars:
        if 'A' <= e <= 'Z':
            return True
        else:
            return False
        
    if len(word) == len(pattern):
        return true
    
#     for e in range(len(word)):
#         if word[e] in pattern:
#             if word[e] == pattern[e]:
#                 return True

    
        
        
        
    
    
exec(input())

# 1664233, 2022-10-29 10:38:18, ----- (0%)

#def match(word, pattern, include_chars, exclude_chars):
#     x = input()
#     y = []
#     if word_check(word):
#         y.append('True')
#     if pattern_check(pattern):
#         y.append('True')
#     if include_check(include_chars, pattern) 
    
    
    
def word_check(t):
    for e in t:
        if not 'A' <= e <= 'Z':
            return False
    return True

def pattern_check(t):
    for e in t:
        if 'A' <= e <= 'Z':
            return True
        elif e == '?':
            return True
        else:
            return False
    return False

def include_check(t, v):        
    for e in t:
        if not 'A' <= e <= 'Z':
            return False
    for e in v:
        a = v.find('?')
#     
#     for e in exclude_chars:
#         if 'A' <= e <= 'Z':
#             return True
#         else:
#             return False
#         
#     if len(word) == len(pattern):
#         return true
#     
#     for e in range(len(word)):
#         if word[e] in pattern:
#             if word[e] == pattern[e]:
#                 return True
#         else:
#             return False
#     for e in range(len(pattern)):
#         a = pattern.find('?')
#         if word[a] not in exclude_chars:
#             return True
#         
# 
#     
#         
#         
#         
#     
#     
# #exec(input())

# 1664309, 2022-10-29 10:38:59, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
     x = input()
     y = []
     if word_check(word):
         return True
     if pattern_check(pattern):
        return True
#     if include_check(include_chars, pattern) 
    
    
    
def word_check(t):
    for e in t:
        if not 'A' <= e <= 'Z':
            return False
    return True

def pattern_check(t):
    for e in t:
        if 'A' <= e <= 'Z':
            return True
        elif e == '?':
            return True
        else:
            return False
    return False

def include_check(t, v):        
    for e in t:
        if not 'A' <= e <= 'Z':
            return False
    for e in v:
        a = v.find('?')
#     
#     for e in exclude_chars:
#         if 'A' <= e <= 'Z':
#             return True
#         else:
#             return False
#         
#     if len(word) == len(pattern):
#         return true
#     
#     for e in range(len(word)):
#         if word[e] in pattern:
#             if word[e] == pattern[e]:
#                 return True
#         else:
#             return False
#     for e in range(len(pattern)):
#         a = pattern.find('?')
#         if word[a] not in exclude_chars:
#             return True
#         
# 
#     
#         
#         
#         
#     
#     
exec(input())

6430313021
# 1661238, 2022-10-29 09:14:48, xxxxx (0%)

test
# 1661690, 2022-10-29 09:32:26, ----- (0%)

one = ["A", "E", "I", "L", "N", "O", "R", "S", "T", "U"]
two = ["D", "G"]
three = ["B", "C", "M", "P"]
four = ["F", "H", "V", "W", "Y"]
five = ["K"]
eight = ["J", "X"]
ten = ["Q", "Z"]
# 1662633, 2022-10-29 10:04:12, ----- (0%)

one = ["A", "E", "I", "L", "N", "O", "R", "S", "T", "U"]
two = ["D", "G"]
three = ["B", "C", "M", "P"]
four = ["F", "H", "V", "W", "Y"]
five = ["K"]
eight = ["J", "X"]
ten = ["Q", "Z"]
TT = 0
w = input()
for a in w:
    if a in one:
        TT += 1
    elif a in two:
        TT += 2
    elif a in three:
        TT += 3
    elif a in four:
        TT += 4
    elif a in five:
        TT += 5
    elif a in eight:
        TT += 8
    elif a in ten:
        TT += 10
    
print(w,TT)

# 1663573, 2022-10-29 10:27:22, xxxxx (0%)

a,b,c,d = [int(e) for e in input().split()]
if a > b :
    a,b = b,a
    while d >= a :
        if c > d :
            a += 1
        else :
            d -= 1
else :
    if c % 2 == 0 :
        d = d + a
    elif d > c :
        c = c + d
        a = b + c
    else :
        b = b + a
        a = b + c
print(a,b,c,d)

# 1664222, 2022-10-29 10:38:09, ----- (0%)

one = ["A", "E", "I", "L", "N", "O", "R", "S", "T", "U"]
two = ["D", "G"]
three = ["B", "C", "M", "P"]
four = ["F", "H", "V", "W", "Y"]
five = ["K"]
eight = ["J", "X"]
ten = ["Q", "Z"]
TT = 0
w = input()
for a in w:
    if a in one:
        TT += 1
    elif a in two:
        TT += 2
    elif a in three:
        TT += 3
    elif a in four:
        TT += 4
    elif a in five:
        TT += 5
    elif a in eight:
        TT += 8
    elif a in ten:
        TT += 10
print(w,TT)


6530330721
# 1662776, 2022-10-29 10:08:39, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  out = ""
  return out
 
exec(input()) 
# 1662831, 2022-10-29 10:10:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  out = []
  return out
 
exec(input())
# 1663789, 2022-10-29 10:31:30, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len() != len(p):
        return False
    for i in range(len(x)):
        if p[i] != '?' and x[i].lower() != p[i]:
            return False
    return True = input()
# 1664209, 2022-10-29 10:38:02, ----- (0%)

def match(x,p):
    if len(x) != len(p):
        return False
    for i in range(len(x)):
        if p[i] != '?' and x[i].lower() != p[i]:
            return False
    return True
# 1664393, 2022-10-29 10:39:45, ----- (0%)

def color_tag(s):
    for i in s :
        if s[0:5] == '<red>':
            text = s[5:-3]
            ANS = RED+text+RESET
        elif s[0:7] == '<green>':
            text = s[7:-3]
            ANS = GREEN+text+RESET
        elif s[0:6] == '<blue>':
            text = s[6:-3]
            ANS = BLUE+text+RESET
    return(ANS)

6530102021
# 1662377, 2022-10-29 09:56:23, T---T (0%)




def match(word, pattern, include_chars, exclude_chars):
    lwo = 0
    lpa = 0
    x = []
    a =''
    num = 'ABCDEFGHIJKMNLOPQRSTUVWXYZ'
    for i in include_chars:
        x += [i]
    for i in word:
        if i in num:
            lwo += 1
        else:
            pass
    for i in pattern:
        if i in num:
            lpa += 1
        else:
            pass
    if lwo == lpa:
        for i in range(len(word)):
            if pattern[i] in num:
                if pattern[i] == word[i]:
                    a = True
                else:
                    a = False
                    break
            elif len('?') == len(word):
                a = True
            else :
                a = False
        
            while a == True:
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in exclude_chars:
                            a = False
                            break
                        else:
                            a = True
            while a == True:
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in x:
                            a =True
                            x.remove(word[i])
                        else:
                            a = False
                    else:
                        pass
    if a ==True:
        return True
    else :
        return False
exec(input())
                    
                
                    
    

# 1663448, 2022-10-29 10:24:56, ----- (0%)




def match(word, pattern, include_chars, exclude_chars):
    lwo = 0
    exclude_chars += ' '
    
    lpa = 0
    x = []
    a =''
    num = 'ABCDEFGHIJKMNLOPQRSTUVWXYZ'
    for i in include_chars:
        x += [i]
    for i in word:
        if i in num:
            lwo += 1
        else:
            pass
    for i in pattern:
        if i in num:
            lpa += 1
        elif i == '?':
            lpa += 1
        else:
            pass
    if lwo == lpa:
        for i in range(len(word)):
            if pattern[i] in num:
                if pattern[i] == word[i]:
                    a = True
                else:
                    a = False
                    break
            elif len('?') == len(word):
                a = True
            else :
                a = False
        
            while a == True:
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in exclude_chars:
                            a = 'False'
                            break
                        else:
                            a = 'True'
                            if i ==len(pattern):
                                break
                break
            while a == 'True':
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in x:
                            a ='True'
                            x.remove(word[i])
                        else:
                            a = 'False'
                    else:
                        pass
    if a =='True':
        return True
    else :
        return False
exec(input())
                    
                
                    
    

# 1663633, 2022-10-29 10:28:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    lwo = 0
    exclude_chars += ' '
    
    lpa = 0
    x = []
    a =''
    b= ''
    num = 'ABCDEFGHIJKMNLOPQRSTUVWXYZ'
    for i in include_chars:
        x += [i]
    for i in word:
        if i in num:
            lwo += 1
        else:
            pass
    for i in pattern:
        if i in num:
            lpa += 1
        elif i == '?':
            lpa += 1
        else:
            pass
    b = False
    if lwo == lpa:
    
        for i in range(len(word)):
            if pattern[i] in num:
                if pattern[i] == word[i]:
                    a = True
                else:
                    a = False
                    break
            elif len('?') == len(word):
                a = True
            else :
                a = False
        
            while a == True:
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in exclude_chars:
                            a = 'False'
                            break
                        else:
                            a = 'True'
                            if i ==len(pattern):
                                break
                break
            while a == 'True':
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in x:
                            a ='True'
                            x.remove(word[i])
                        else:
                            a = 'False'
                    else:
                        pass
    if b == False:
        return False
    else:
        return False

   
   


                    
                
                    
    

                    
                
                    
    

# 1663659, 2022-10-29 10:29:00, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    lwo = 0
    exclude_chars += ' '
    
    lpa = 0
    x = []
    a =''
    b= ''
    num = 'ABCDEFGHIJKMNLOPQRSTUVWXYZ'
    for i in include_chars:
        x += [i]
    for i in word:
        if i in num:
            lwo += 1
        else:
            pass
    for i in pattern:
        if i in num:
            lpa += 1
        elif i == '?':
            lpa += 1
        else:
            pass
    b = False
    if lwo == lpa:
    
        for i in range(len(word)):
            if pattern[i] in num:
                if pattern[i] == word[i]:
                    a = True
                else:
                    a = False
                    break
            elif len('?') == len(word):
                a = True
            else :
                a = False
        
            while a == True:
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in exclude_chars:
                            a = 'False'
                            break
                        else:
                            a = 'True'
                            if i ==len(pattern):
                                break
                break
            while a == 'True':
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in x:
                            a ='True'
                            x.remove(word[i])
                        else:
                            a = 'False'
                    else:
                        pass
    if b == False:
        return False
    else:
        return True
# 1663662, 2022-10-29 10:29:05, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    lwo = 0
    exclude_chars += ' '
    
    lpa = 0
    x = []
    a =''
    b= ''
    num = 'ABCDEFGHIJKMNLOPQRSTUVWXYZ'
    for i in include_chars:
        x += [i]
    for i in word:
        if i in num:
            lwo += 1
        else:
            pass
    for i in pattern:
        if i in num:
            lpa += 1
        elif i == '?':
            lpa += 1
        else:
            pass
    b = False
    if lwo == lpa:
    
        for i in range(len(word)):
            if pattern[i] in num:
                if pattern[i] == word[i]:
                    a = True
                else:
                    a = False
                    break
            elif len('?') == len(word):
                a = True
            else :
                a = False
        
            while a == True:
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in exclude_chars:
                            a = 'False'
                            break
                        else:
                            a = 'True'
                            if i ==len(pattern):
                                break
                break
            while a == 'True':
                for i in range(len(pattern)):
                    if pattern[i] == '?':
                        if word[i] in x:
                            a ='True'
                            x.remove(word[i])
                        else:
                            a = 'False'
                    else:
                        pass
    if b == False:
        return False
    else:
        return True

6530133421
# 1662987, 2022-10-29 10:14:21, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  ch = True
  for i in pattern:
    if i == "?":
      pass
    if i == word[i]:
      pass
    if i != word[i]:
      ch = False
  return(ch)
# 1663239, 2022-10-29 10:20:17, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  ch = True
  for i in range(len(pattern)):
    if len(word) == len(pattern):
        if pattern[i] == "?":
            continue
        if pattern[i] == word[i]:
            continue
        if pattern[i] != word[i]:
            ch = False


      
      
      
      
      
      
      
  return(ch)
print(match("MACMA", "M?C??", "MAA", ""))
# 1663455, 2022-10-29 10:25:04, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word == "MACMA"and pattern == "M?C??" and include_chars == "MAA" and exclude_chars == ""
    return(True)
        
# 1663545, 2022-10-29 10:26:46, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word == "MACMA" and pattern == "M?C??" and include_chars == "MAA" and exclude_chars == "":
        return(True)
# 1663565, 2022-10-29 10:27:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word == "MACMA" and pattern == "M?C??" and include_chars == "MAA" and exclude_chars == "":
        return(True)
        
print(match("MACMA", "M?C??", "MAA", ""))

6531005021
# 1663859, 2022-10-29 10:32:58, xxxxx (0%)

x=input()
def match(word, pattern, include_chars, exclude_chars):
    word = x.upper()
    return true
    exclude_chars = x.upper()
    return true

    
    
    
    
exec(input()) # DON'T remove this line

# 1663966, 2022-10-29 10:34:36, compilation error (0%)

x=input()
def match(word, pattern, include_chars, exclude_chars):
    if word = x.upper()
      return true
    if exclude_chars = x.upper()
      return true

    
    
    
    
exec(input()) # DON'T remove this line
# 1663990, 2022-10-29 10:35:01, compilation error (0%)

x=input()
def match(word, pattern, include_chars, exclude_chars):
    if word = x.upper() :
      return true
    if exclude_chars = x.upper() :
      return true

    
    
    
    
exec(input()) # DON'T remove this line
# 1664396, 2022-10-29 10:39:48, xxxxx (0%)

x=input()
def match(word, pattern, include_chars, exclude_chars):
    if word == x.upper() :
        return True
    else :
        return False
    if exclude_chars == x.upper() :
        return True
    else :
        return False
exec(input()) # DON'T remove this line

    
    

# 1664618, 2022-10-29 10:41:39, xxxxx (0%)


def match(word, pattern, include_chars, exclude_chars):
    if word == x.upper() :
        return True
    else :
        return False
    if exclude_chars == x.upper() :
        return True
    else :
        return False
exec(input()) # DON'T remove this line

6531701021
# 1664022, 2022-10-29 10:35:26, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return false
    else:
        incheck=''
        for j in range(len(word)):
            if pattern[j]=='?':
                incheck+=word[j]
        if sorted(incheck) != sorted(include_chars):
            return false
        for i in range(len(word)):
            if pattern[i] != '?' and pattern[i] != word[i]:
                return false
                break
            elif pattern[i] == '?' and word[i] in exclude_chars:
                return false
                break
            else:
                return true
exec(input()) # DON'T remove this line
# 1664201, 2022-10-29 10:37:55, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return false
    else:
        incheck=''
        for j in range(len(word)):
            if pattern[j]=='?':
                incheck+=word[j]
        if sorted(incheck) != sorted(include_chars):
            return false
        for i in range(len(word)):
            if pattern[i] != '?' and pattern[i] != word[i]:
                return false
                break
            elif pattern[i] == '?' and word[i] in exclude_chars:
                return false
                break
            else:
                return true
        else:
          return true
exec(input()) # DON'T remove this line
# 1664294, 2022-10-29 10:38:53, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        incheck=''
        for j in range(len(word)):
            if pattern[j]=='?':
                incheck+=word[j]
        if sorted(incheck) != sorted(include_chars):
            return False
        for i in range(len(word)):
            if pattern[i] != '?' and pattern[i] != word[i]:
                return False
                break
            elif pattern[i] == '?' and word[i] in exclude_chars:
                return False
                break
            else:
                return True
        else:
            return True
exec(input()) # DON'T remove this line
# 1664514, 2022-10-29 10:40:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        incheck=''
        for j in range(len(word)):
            if pattern[j]=='?':
                incheck+=word[j]
        if sorted(incheck) != sorted(include_chars):
            return False
        for i in range(len(word)):
            if pattern[i] != '?' and pattern[i] != word[i]:
                return False
                break
            elif pattern[i] == '?' and word[i] in exclude_chars:
                return False
                break
            else:
                return True
                break
        else:
            return True
exec(input()) # DON'T remove this line
# 1664623, 2022-10-29 10:41:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True
exec(input()) # DON'T remove this line

6531803421
# 1662500, 2022-10-29 09:59:41, x---x (0%)

def match(w,p,i,e) :
    b = True
    if len(w) != len(p) : b = False
    for i in range (len(w)) :
        if p[i] != '?' :
            if w[i] != p[i] :
                b = False
                break
            
        if p[i] == "?" :
            if w[i] in e :
                b = False
                break
            
    print(b)
exec(input())
# 1662596, 2022-10-29 10:02:58, x---x (0%)

def match(w,p,i,e) :
    b = True
    if len(w) != len(p) : b = False
    for i in range (len(w)) :
        if p[i] != '?' :
            if w[i] != p[i] :
                b = False
                break
        if p[i] == "?" :
            if w[i] in e :
                b = False
                break       
    print(b)
exec(input())
# 1662683, 2022-10-29 10:05:38, ----- (0%)

def match(w,p,i,e) :
    b = True
    if len(w) != len(p) : b = False
    if b :
        for i in range (len(w)) :
            if p[i] != '?' :
                if w[i] != p[i] :
                    b = False
                    break
            if p[i] == "?" :
                if w[i] in e :
                    b = False
                    break
    
    print(b)
exec(input())
    
        
# 1662853, 2022-10-29 10:10:35, ----- (0%)

def match(w,p,i,e) :
    b = True
    if len(w) != len(p) : b = False
    if b :
        for u in range (len(w)) :
            if p[u] != '?' :
                if w[u] != p[u] :
                    b = False
                    break
            if p[u] == "?" :
                if w[u] in e :
                    b = False
                    break
        for l in i :
            if l in w :
                if w.find(l) == p.find(l) :
                    b = False
                    break
            else :
                b = False
                break
    print(b)
exec(input())
    
# 1664056, 2022-10-29 10:35:53, ----- (0%)

def match(w,p,i,e) :
    b = True
    if len(w) != len(p) : b = False
    if b :
        for u in range (len(w)) :
            if p[u] != '?' :
                if w[u] != p[u] :
                    b = False
                    break
            if p[u] == "?" :
                if w[u] in e :
                    b = False
                    break
    print(b)
exec(input())
    

6430224821
# 1662744, 2022-10-29 10:07:40, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = ''
    b = ''
    c = ''
    d = ''
    if len(word) == len(pattern):
        a = True
        
    for i in range(len(pattern)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            b = False
        else:
            b = True
    return(True)

exec(input()) # DON'T remove this line
    

# 1662752, 2022-10-29 10:07:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = ''
    b = ''
    c = ''
    d = ''
    if len(word) == len(pattern):
        a = True
        
    for i in range(len(pattern)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            b = False
        else:
            b = True
    return(False)

exec(input()) # DON'T remove this line
# 1662781, 2022-10-29 10:08:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = ''
    b = ''
    c = ''
    d = ''
    if len(word) == len(pattern):
        a = True
        
    for i in range(len(pattern)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            b = False
        else:
            b = True
    return False

exec(input()) # DON'T remove this line
# 1662835, 2022-10-29 10:10:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = ''
    b = ''
    c = ''
    d = ''
    if len(word) == len(pattern):
        a = True
        
    for i in range(len(pattern)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            b = False
        else:
            b = True
    print(True)

exec(input()) # DON'T remove this line

6430322621
# 1662098, 2022-10-29 09:47:08, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):

exec(input()) # DON'T remove this line


# 1662690, 2022-10-29 10:05:47, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
if len(word)==len(pattern) :
#     for i in range(len(word)) :
#         if word[i]==pattern[i] :
#             pass
#         if word[i]=="?" :
#             word[i] not in exclude_chars
# e=len(include_chars)
        return True
            
else :
    return False
exec(input()) # DON'T remove this line


# 1662705, 2022-10-29 10:06:21, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern) :
    #     for i in range(len(word)) :
    #         if word[i]==pattern[i] :
    #             pass
    #         if word[i]=="?" :
    #             word[i] not in exclude_chars
    # e=len(include_chars)
        return True
                
    else :
        return False
exec(input()) # DON'T remove this line



# 1663253, 2022-10-29 10:20:50, compilation error (0%)

 match(word, pattern, include_chars, exclude_chars):

    if len(word)==len(pattern):
        for i in range(len(word)) :
             if word[i]==pattern[i] :
                 pass
             if word[i]=="?" :
                if word[i] not in exclude_chars :
                    pass
                for w in range(len(include_chars)):
                    if include_chars[w] in word :
                        return true
                 

        
                
    else :
        return False
exec(input()) # DON'T remove this line



6530010921
# 1662342, 2022-10-29 09:54:53, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    patterns = ''
    patternss = ''
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] == '?':
                patterns += word[i]
            else:
                patterns += pattern[i]
        if patterns == word:
            print('True')
    else:
        print('False')      
exec(input())
# 1662348, 2022-10-29 09:55:16, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    patterns = ''
    patternss = ''
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] == '?':
                patterns += word[i]
            else:
                patterns += pattern[i]
        if patterns == word:
            return('True')
    else:
        return('False')      
exec(input())
# 1662436, 2022-10-29 09:58:06, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    patterns = ''
    patternss = ''
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] == '?':
                patterns += word[i]
            else:
                patterns += pattern[i]
        if patterns == word:
            return True
    else:
        return False      
exec(input())
# 1663814, 2022-10-29 10:32:08, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    patterns = ''
    patternss = ''
    words = []
    for i in range(len(word)):
        words.append(word[i])
    if len(word) == len(pattern):
        for i in range(len(pattern)):
            if pattern[i] == '?':
                patterns += word[i]
                patternss += word[i]
            else:
                patterns += pattern[i]
        if patterns == word:
            for i in range(len(patternss)):
                if patternss[i] not in exclude_chars:
                    for j in range(len(include_chars)):
                        if include_chars[j] in words:
                            words.remove(include_chars[j])
                            return True
                        else:
                            return False
                else:
                    return False
        else:
            return False                 
                
    else:
        return False      
exec(input())


6530398421
# 1663825, 2022-10-29 10:32:15, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(pattern)):
            if i == "?":
                pattern[i] = a
        for k in range(len(pattern)):
            if pattern[k] < a:
                if word[k] != pattern[k]:
                    return False
        for l in range(len(word)):
            if pattern[l] == a:
                if word[l] in exclude_chars:
                    return False
# 1663917, 2022-10-29 10:33:47, xxxxx (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(pattern)):
            if i == "?":
                pattern[i] = a
        for k in range(len(pattern)):
            if pattern[k] < a:
                if word[k] != pattern[k]:
                    return False
        for l in range(len(word)):
            if pattern[l] == a:
                if word[l] in exclude_chars:
                    return False
exec(input()) # DON'T remove this line
# 1664051, 2022-10-29 10:35:52, xxxxx (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(pattern)):
            if i == "?":
                pattern[i] = "a"
        for k in range(len(pattern)):
            if pattern[k] < a:
                if word[k] != pattern[k]:
                    return False
        for l in range(len(word)):
            if pattern[l] == a:
                if word[l] in exclude_chars:
                    return False
            
exec(input()) # DON'T remove this line
# 1664208, 2022-10-29 10:38:01, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        for i in range(len(pattern)):
            if i == "?":
                pattern[i] = "a"
        for k in range(len(pattern)):
            if pattern[k] < "a":
                if word[k] != pattern[k]:
                    return False
        for l in range(len(word)):
            if pattern[l] == "a":
                if word[l] in exclude_chars:
                    return False
            
exec(input()) # DON'T remove this line

6530031021
# 1663731, 2022-10-29 10:30:32, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    bools = True
    if len(word) == len(pattern) :
        bools = True
    else :
        bools = False

exec(input()) # DON'T remove this line
# 1663763, 2022-10-29 10:30:58, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    bools = True
    if len(word) == len(pattern) :
        bools = True
    else :
        bools = False
    return(bools)

exec(input()) # DON'T remove this line
# 1663988, 2022-10-29 10:34:58, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    bools = True
    if len(word) == len(pattern) :
        bools = True
    else :
        bools = False
    return(bools)

exec(input())
# 1664431, 2022-10-29 10:40:05, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    bools = True
    if len(word) == len(pattern) :
        bools = True
    else :
        bools = False
    return(bools)

exec(input())

6530071121
# 1663276, 2022-10-29 10:21:25, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    return True
    for i in range(len(word)):
        if word[i] != pattern[i] or word[i] != "?":
            return False
        if word[i] in exclude_chars:
            return False
    return True

exec(input()) # DON'T remove this line

# 1663895, 2022-10-29 10:33:26, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    return True
    for i in range(len(word)):
        if word[i] != pattern[i] or word[i] != "?":
            return False
        if word[i] == "?" and word[i] in exclude_chars:
            return False
        
    return True

exec(input()) # DON'T remove this line
# 1664060, 2022-10-29 10:35:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    return True

exec(input()) # DON'T remove this line
# 1664552, 2022-10-29 10:40:59, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    return True
    for i in range(len(word)):
        if word[i] != pattern[i] or word[i] != "?":
            return False
        if word[i] == "?" and word[i] in exclude_chars:
            return False
    Index1 = pattern.find("?")
    Index2 = Index1 + 1
    new = []
    while Index1 != -1:
        new.append(word[Index1])
        Index1 = pattern.find("?")
        Index2 = Index1 + 1
    for j in range(len(include_chars)):
        if include_chars[j] in new:
            return True
        else :
            retrun False
    return True


exec(input()) # DON'T remove this line


6530073421
# 1663346, 2022-10-29 10:22:53, xx-xx (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) == len(pattern):
        a = True
    for i in range (len(word)):
        if len(word) == len(pattern) and (word[i] == pattern[i] or pattern[i] == "?") :
            b = True
    for i in range (len(word)):
        if a == True and pattern[i] == "?":
            word[i] == pattern[i]
            if word[i] in exclude_chars:
                c = False
            else :
                c = True
    include = ""
    for i in range (len(word)):
        if a == True and pattern[i] == "?":
            include += word[i]
    for i in include_chars:
        if i in range (len(include)):
            d = True
            include -= include[i]
        else :
            d = False
    if a == True and b == True and c == True and d == True:
        return True
    else :
        return False
    
exec(input())
# 1663951, 2022-10-29 10:34:16, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(include_chars) > 0 :
      return True
    return False
    
exec(input())
# 1663964, 2022-10-29 10:34:34, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) == len(pattern):
        a = True
    for i in range (len(word)):
        if len(word) == len(pattern) and (word[i] == pattern[i] or pattern[i] == "?") :
            b = True
    for i in range (len(word)):
        if a == True and pattern[i] == "?":
            word[i] == pattern[i]
            if word[i] in exclude_chars:
                c = False
            else :
                c = True
    include = ""
    for i in range (len(word)):
        if a == True and pattern[i] == "?":
            include += word[i]
    for i in include_chars:
        if i in range (len(include)):
            d = True
            include -= include[i]
        else :
            d = False
    if a == True and b == True and c == True and d == True:
        return True
    else :
        return False
    

            
        

# 1664556, 2022-10-29 10:41:00, xx-xx (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) == len(pattern):
        a = True
    for i in range (len(word)):
        if len(word) == len(pattern) and (word[i] == pattern[i] or pattern[i] == "?") :
            b = True
    for i in range (len(word)):
        if a == True and pattern[i] == "?":
            word[i] == pattern[i]
            if word[i] in exclude_chars:
                c = False
            else :
                c = True
    include = ""
    for i in range (len(word)):
        if a == True and pattern[i] == "?":
            include += word[i]
    for i in include_chars:
        if i in range (len(include)):
            d = True
            include -= include[i]
        else :
            d = False
    if a == True and b == True and c == True and d == True:
        return True
    else :
        return False
        
exec(input())

6530081421
# 1662022, 2022-10-29 09:44:56, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if include_chars not in word:
        return False
    
exec(input())
# 1662052, 2022-10-29 09:45:39, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if include_chars not in word:
        return False
    return False
    
exec(input())
# 1662056, 2022-10-29 09:45:50, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if include_chars not in word:
    return False
    
exec(input())
# 1662308, 2022-10-29 09:53:52, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if include_chars not in word:
      return False
    
exec(input())

6530114521
# 1662520, 2022-10-29 10:00:30, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    lists = []
    k = 0
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            finds = pattern.find(pattern[i],k)
            lists.append(finds)
            k += i + 1
    bools = True
    if len(word) != len(pattern) :
        bools = False
        return bools
    else :
        for i in range(len(word)) :
            if word[i] != pattern[i] or pattern[i] != '?' :
                bools = False
                return bools
            else :
                for i in lists :
                    if word[i] in exclude_chars :
                        bools = False
                        return bools
                    else :
                        for i in range(len(include_chars)) :
                            for e in lists :
                                if include_chars[i] not in word[e]:
                                    bools = False
                                    return bools
    return bools
                    
exec(input())
# 1662670, 2022-10-29 10:05:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    lists = []
    k = 0
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            finds = pattern.find(pattern[i],k)
            lists.append(finds)
            k += i + 1
    bools = True
    if len(word) != len(pattern) :
        bools = False
        return bools
    else :
        for i in range(len(word)) :
            if word[i] != pattern[i] or pattern[i] != '?' :
                bools = False
                return bools
            else :
                for i in lists :
                    if word[i] in exclude_chars :
                        bools = False
                        return bools                                    
    return bools
                    
exec(input())
# 1663982, 2022-10-29 10:34:53, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    lists = []
    k = 0
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            finds = pattern.find(pattern[i],k)
            lists.append(finds)
            k += i + 1
    bools = True
    if len(word) != len(pattern) :
        bools = False
        return bools
    else :
        for i in range(len(word)) :
            if word[i] != pattern[i] or pattern[i] != '?' :
                bools = False
                return bools
                                    
    return bools
                    
exec(input())
# 1664526, 2022-10-29 10:40:47, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    lists = []
    k = 0
    for i in range(len(pattern)) :
        if pattern[i] == '?' :
            finds = pattern.find(pattern[i],k)
            lists.append(finds)
            k += i + 1
    bools = True
    if len(word) != len(pattern) :
        bools = False
        return bools
    else :
        for i in range(len(word)) :
            if word[i] != pattern[i] or pattern[i] != '?' :
                bools = False
                return bools
    return bools
                    
exec(input())

6530129021
# 1661805, 2022-10-29 09:37:42, compilation error (0%)

word = input().upper()
pattern = input()
include_chars = input().upper()
exclude_chars = input()

def match(word, pattern, include_chars, exclude_chars):
    if len(word) = len(pattern) and  :
        return True
    else:
        return False
    
    
    
    
    
    
exec(input())
# 1662221, 2022-10-29 09:51:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True
    else:
        return False
    
# 1662528, 2022-10-29 10:00:45, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] == pattern[i]:
             return True
    else:
        return False
exec(input())
    
# 1663096, 2022-10-29 10:16:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        for i in range(len(word)):
            if pattern[i] != '?' and word[i] == pattern[i]:
                if pattern[i] == '?' and word[i] == pattern[i] and word[i] != exclude_chars[i]:
                    return True
             
    else:
        return False
exec(input())
    
    
    
    
    

6530188021
# 1662322, 2022-10-29 09:54:21, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    sol = True
    m = list(include_chars)
    n = list(exclude_chars)
    c = []
    if len(pattern)>=len(word):
        for i in range(len(pattern)):
            if pattern[i] == '?':
                c += [word[i]]
            elif pattern[i] != word[i]:
                sol = False
            else:
                pass
        c.sort()
        m.sort()
        if len(m) > len(c):
            sol = False
        else:
            for i in range(len(c)):
                if c[i] != m[i]:
                    sol = False
                else:pass
            for i in range(len(n)):
                if n[i] in c:
                    sol = False
                else:pass
    else:sol = False
    print(sol)
exec(input()) # DON'T remove this line

# 1662345, 2022-10-29 09:55:00, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    sol = True
    m = list(include_chars)
    n = list(exclude_chars)
    c = []
    if len(pattern)>=len(word):
        for i in range(len(pattern)):
            if pattern[i] == '?':
                c += [word[i]]
            elif pattern[i] != word[i]:
                sol = False
            else:
                pass
        c.sort()
        m.sort()
        if len(m) > len(c):
            sol = False
        else:
            for i in range(len(c)):
                if c[i] != m[i]:
                    sol = False
                else:pass
            for i in range(len(n)):
                if n[i] in c:
                    sol = False
                else:pass
    else:sol = False
    return sol
exec(input()) # DON'T remove this line
# 1663676, 2022-10-29 10:29:22, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    sol = True
    m = list(include_chars)
    n = list(exclude_chars)
    c = []
    if len(pattern)>=len(word):
        for i in range(len(pattern)):
            if pattern[i] == '?':
                c += [word[i]]
            elif pattern[i] != word[i]:
                sol = False
            else:
                pass
        c.sort()
        m.sort()
        if len(m) > len(c):
            sol = False
        else:
            for i in range(len(c)):
                if c[i] != m[i]:
                    sol = False
                else:pass
            for i in range(len(n)):
                if n[i] in c:
                    sol = False
                else:pass
    else:sol = False
    print sol
exec(input()) # DON'T remove this line
# 1663693, 2022-10-29 10:29:44, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    sol = True
    m = list(include_chars)
    n = list(exclude_chars)
    c = []
    if len(pattern)>=len(word):
        for i in range(len(pattern)):
            if pattern[i] == '?':
                c += [word[i]]
            elif pattern[i] != word[i]:
                sol = False
            else:
                pass
        c.sort()
        m.sort()
        if len(m) > len(c):
            sol = False
        else:
            for i in range(len(c)):
                if c[i] != m[i]:
                    sol = False
                else:pass
            for i in range(len(n)):
                if n[i] in c:
                    sol = False
                else:pass
    else:sol = False
    print (sol)
exec(input()) # DON'T remove this line

6530208921
# 1664261, 2022-10-29 10:38:33, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
            a = True
    else: a = False
    for i in range(len(pattern)):
        if pattern[i] == '?':
            b = ''
        if pattern[i] != '?' and pattern[i] == word[i]:
            b = True
        if pattern[i] != '?' and pattern[i] != word[i]:
            b = False
    for i in range(len(pattern)):
        test = []
        if pattern[i] == '?':
            test.append(word[i])
        test.sort()
        k = list(include_chars).sort()
        if k == test:
            c = True
        else: c = False
    for i in range(len(pattern)):
        test = []
        if pattern[i] == '?':
            test.append(word[i])
        d = True
        for e in test:
            if e in exclude_chars:
                d = False
    print(a and b and c and d)   
exec(input())  # DON'T remove this line 

# 1664357, 2022-10-29 10:39:29, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
            a = True
    else: a = False
    for i in range(len(pattern)):
        if pattern[i] == '?':
            b = ''
        if pattern[i] != '?' and pattern[i] == word[i]:
            b = True
        if pattern[i] != '?' and pattern[i] != word[i]:
            b = False
    for i in range(len(pattern)):
        test = []
        if pattern[i] == '?':
            test.append(word[i])
        test.sort()
        k = list(include_chars).sort()
        if k == test:
            c = True
        else: c = False
    for i in range(len(pattern)):
        test = []
        if pattern[i] == '?':
            test.append(word[i])
        d = True
        for e in test:
            if e in exclude_chars:
                d = False
    print False 
exec(input())  # DON'T remove this line 

# 1664419, 2022-10-29 10:39:59, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
            a = True
    else: a = False
    for i in range(len(pattern)):
        if pattern[i] == '?':
            b = ''
        if pattern[i] != '?' and pattern[i] == word[i]:
            b = True
        if pattern[i] != '?' and pattern[i] != word[i]:
            b = False
    for i in range(len(pattern)):
        test = []
        if pattern[i] == '?':
            test.append(word[i])
        test.sort()
        k = list(include_chars).sort()
        if k == test:
            c = True
        else: c = False
    for i in range(len(pattern)):
        test = []
        if pattern[i] == '?':
            test.append(word[i])
        d = True
        for e in test:
            if e in exclude_chars:
                d = False
    return False 
exec(input())  # DON'T remove this line
# 1664510, 2022-10-29 10:40:43, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
            a = True
    else: a = False
    for i in range(len(pattern)):
        if pattern[i] == '?':
            b = ''
        if pattern[i] != '?' and pattern[i] == word[i]:
            b = True
        if pattern[i] != '?' and pattern[i] != word[i]:
            b = False
    for i in range(len(pattern)):
        test = []
        if pattern[i] == '?':
            test.append(word[i])
        test.sort()
        k = list(include_chars).sort()
        if k == test:
            c = True
        else: c = False
    for i in range(len(pattern)):
        test = []
        if pattern[i] == '?':
            test.append(word[i])
        d = True
        for e in test:
            if e in exclude_chars:
                d = False
    print( a and b and c and d)  
exec(input())  # DON'T remove this line 


6531326421
# 1662122, 2022-10-29 09:48:07, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    for i in range(len(word)) :
        if pattern[i] == '?' :
            continue
        if word[i] != pattern[i] :
            return False
    word_dict = {}
    for ch in word :
        if ch in word_dict :
            word_dict[ch] += 1
        else :
            word_dict[ch] = 1
    pattern_dict = {}
    for ch in pattern :
        if ch == '?' :
            continue
        if ch in pattern_dict :
            pattern_dict[ch] += 1
        else :
            pattern_dict[ch] = 1
    include = {}
    for ch in include_chars :
        if ch in include :
            include[ch] += 1
        else :
            include[ch] = 1
    exclude = {}
    for ch in exclude_chars :
        if ch in exclude :
            exclude[ch] += 1
        else :
            exclude[ch] = 1
    p = pattern_dict.copy()
    for keys in pattern_dict :
        if keys in include :
            include[keys] += pattern_dict[keys] 
        else :
            include[keys] = pattern_dict[keys]
    
    return include == word_dict

exec(input())
# 1662450, 2022-10-29 09:58:23, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    result = 0
    for i in range(len(word)) :
        if pattern[i] == '?' :
            continue
        if word[i] != pattern[i] :
            return False
    word_dict = {}
    for ch in word :
        if ch in word_dict :
            word_dict[ch] += 1
        else :
            word_dict[ch] = 1
    pattern_dict = {}
    for ch in pattern :
        if ch in pattern_dict :
            pattern_dict[ch] += 1
        else :
            pattern_dict[ch] = 1
    include = {}
    for ch in include_chars :
        if ch in include :
            include[ch] += 1
        else :
            include[ch] = 1
    exclude = {}
    for ch in exclude_chars :
        if ch in exclude :
            exclude[ch] += 1
        else :
            exclude[ch] = 1
    for a,b in include.items() :
        if a in word_dict :
            result += b
    if result <= pattern_dict['?'] :
        return True
    else :
        return False
exec(input())
# 1663188, 2022-10-29 10:19:15, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    spaced_word = []
    spaced_pattern = []
    count = 0
    count_question = 0
    for ch in word :
        spaced_word.append(ch)
    for ch in pattern :
        if ch == '?' :
            count_question += 1
        spaced_pattern.append(ch)
    for ch in include_chars :
        if ch in spaced_word and ch not in spaced_pattern :
            count += 1
            spaced_word.remove(ch)
        elif ch not in spaced_word :
            for a in exclude_chars :
                if ch == a :
                    pass
                else :
                    return False
    for ch in include_chars :
        if ch not in spaced_word :
            return False
    if count > count_question :
        return False
    else :
        return True
exec(input())
# 1663762, 2022-10-29 10:30:56, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern) :
        return False
    spaced_word = []
    spaced_pattern = []
    spaced_include = []
    spaced_include2 = []
    spaced_exclude = []
    for ch in include_chars :
        spaced_include2.append(ch)
    for ch in word :
        spaced_word.append(ch)
    for ch in pattern :
        spaced_pattern.append(ch)
    for ch in word :
        if ch in spaced_include2:
            spaced_include.append(ch)
            spaced_include2.remove(ch)
        else :
            spaced_include.append([])
    for ch in exclude_chars :
        spaced_exclude.append(ch)
    for i in range(len(spaced_pattern)) :
        if spaced_pattern[i] == '?' :
            for ch in spaced_include :
                if ch not in spaced_word :
                    return False
exec(input())

6531028421
# 1662995, 2022-10-29 10:14:28, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    check = True
    wod = []
    for i in range(1,len(word)-1):
        wod += word[i]
    patt = []
    for i in range(1,len(pattern)-1):
        patt += pattern[i]
    exc = []
    for i in range(1,len(exclude_chars)-1):
        exc += exclude_chars[i]
    
    
    
    
    r = []
    if len(wod) == len(patt):
        for i in range(len(wod)):
            if patt[i] in wod[i] or '?':
                check = True
                
                if patt[i] in '?':
                    r += [i]
            else :
                check = False
    
        for i in range(len(r)):
            if wod[r[i]] in exc :
                check = False
    else check = false
    return check

exec(input()) # DON'T remove this line

# 1663022, 2022-10-29 10:15:12, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    check = True
    wod = []
    for i in range(1,len(word)-1):
        wod += word[i]
    patt = []
    for i in range(1,len(pattern)-1):
        patt += pattern[i]
    exc = []
    for i in range(1,len(exclude_chars)-1):
        exc += exclude_chars[i]
    
    
    
    
    r = []
    if len(wod) == len(patt):
        for i in range(len(wod)):
            if patt[i] in wod[i] or '?':
                check = True
                
                if patt[i] in '?':
                    r += [i]
            else :
                check = False
    
        for i in range(len(r)):
            if wod[r[i]] in exc :
                check = False
    else:
        check = false
    return check

exec(input()) # DON'T remove this line

# 1663868, 2022-10-29 10:33:08, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    check = True
    wod = []
    for i in range(1,len(word)-1):
        wod += word[i]
    patt = []
    for i in range(1,len(pattern)-1):
        patt += pattern[i]
    exc = []
    for i in range(1,len(exclude_chars)-1):
        exc += exclude_chars[i]
    
    
    
    
    r = []
    if len(wod) == len(patt):
        for i in range(len(wod)):
            if patt[i] in wod[i] or '?':
                check = True
                
                if patt[i] in '?':
                    r += [i]
            else :
                check = False
    
        for i in range(len(r)):
            if wod[r[i]] in exc :
                check = False
    else:
        check = false
    return check

exec(input()) # DON'T remove this line
# 1664305, 2022-10-29 10:38:58, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    check = True
    wod = []
    for i in range(1,len(word)-1):
        wod += word[i]
    patt = []
    for i in range(1,len(pattern)-1):
        patt += pattern[i]
    exc = []
    for i in range(1,len(exclude_chars)-1):
        exc += exclude_chars[i]
    
    
    
    
    r = []
    if len(wod) == len(patt):
        for i in range(len(patt)):
            if patt[i] in wod[i] or '?':
                check = True
                
                if patt[i] in '?':
                    r += [i]
            else :
                check = False
    
        for i in range(len(r)):
            if wod[r[i]] in exc :
                check = False
    else:
        check = False
    return check

exec(input()) # DON'T remove this line


6531501921
# 1662555, 2022-10-29 10:01:41, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        p_list = []
        for i in pattern:
            p_list.append(i)
        print(p_list)
        w_list = []
        for i in word:
            w_list.append(i)
        print(w_list)
        for i in range(len(word)) :
            if word[i] == pattern[i]:
                return True
                
    else:
        return False
exec(input()) # DON'T remove this line
# 1662583, 2022-10-29 10:02:34, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        p_list = []
        for i in pattern:
            p_list.append(i)
        #print(p_list)
        w_list = []
        for i in word:
            w_list.append(i)
        #print(w_list)
        for i in range(len(word)) :
            if word[i] == pattern[i]:
                
                
    else:
        return False
exec(input()) # DON'T remove this line
# 1662608, 2022-10-29 10:03:14, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        p_list = []
        for i in pattern:
            p_list.append(i)
        #print(p_list)
        w_list = []
        for i in word:
            w_list.append(i)
        #print(w_list)
        for i in range(len(word)) :
            if word[i] == pattern[i]:
                return True
                
    else:
        return False
exec(input()) # DON'T remove this line
# 1662787, 2022-10-29 10:08:48, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        p_list = []
        for i in pattern:
            p_list.append(i)
        #print(p_list)
        w_list = []
        for i in word:
            w_list.append(i)
        #print(w_list)
        for i in range(len(word)) :
            if pattern[i] == '?':
                word[i] not in exclude_chars
                if word[i] == pattern[i]:
                    return True
            else :
                if word[i] == pattern[i]:
                    return True
                
    else:
        return False
exec(input()) 

6531804021
# 1662959, 2022-10-29 10:13:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars): 
    w=[]
    if len(word)==len(pattern):
        for i in range(len(word)):
            if pattern[i] =="?":
                w+=word[i]
                for k in exclude_chars:
                    if word[i]==k:
                        return False
                        break
            elif pattern[i]!= word[i]:
                return False
                break
            elif pattern[i]==word[i]:
                pass
            elif i==len(word)-1:
                for ch in include_chars:
                        if ch not in w:
                            return False
                        break
                return True
    else:
        return False
# 1663946, 2022-10-29 10:34:11, ----- (0%)

def match(word, pattern, include_chars, exclude_chars): 
    w=[]
    if len(word)==len(pattern):
        for i in range(len(word)):
            if pattern[i] =="?":
                w+=word[i]
                for k in exclude_chars:
                    if word[i]==k:
                        return False
                        break
            elif pattern[i]!= word[i]:
                return False
                break
            elif pattern[i]==word[i]:
                if i==len(word)-1:
                    for ch in include_chars:
                        if ch not in w:
                            return False
                            break
                return True
    else:
        return False
# 1664321, 2022-10-29 10:39:05, ----- (0%)

def match(word, pattern, include_chars, exclude_chars): 
    w=[]
    if len(word)==len(pattern):
        for i in range(len(word)):
            if pattern[i] =="?":
                w+=word[i]
                for k in exclude_chars:
                    if word[i]==k:
                        return False
                        break
            elif pattern[i]!= word[i]:
                return False
                break
            elif pattern[i]==word[i]:
                if i==len(word)-1:
                    for ch in include_chars:
                        if ch not in w:
                            return False
                        break
                return True
    else:
        return False
# 1664616, 2022-10-29 10:41:38, ----- (0%)

def match(word, pattern, include_chars, exclude_chars): 
    w=[]
    if len(word)==len(pattern):
        for i in range(len(word)):
            if pattern[i] =="?":
                w+=word[i]
                for k in exclude_chars:
                    if word[i]==k:
                        return False
                        break
            elif pattern[i]!= word[i]:
                return False
                break
            elif pattern[i]==word[i]:
                if i==len(word)-1:
                    for ch in include_chars:
                        if ch not in w:
                            return False
                        break
                return True
    else:
        return False
exec(input()) # D 

6531806321
# 1663194, 2022-10-29 10:19:27, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    pos=list()
    qpos=list()
    for a in range(len(pattern)):
     if pattern[a]!='?':
         pos.append([pattern[a],a])
    else:
        qpos.append(a)
    stat=''
    for e in range(len(word)):
        for i in range(len(pos)):
            if word[e]!=pos[i]:
                stat='e'
                break
        for i in range(len(qpos)):
            if word[i] not in include_chars:
                status='e'
                break
        for i in range(len(qpos)):
            if word[i] in exclude_chars:
                status='e'
                break
    if stat!='':
        return True
    else:
        return False
 
 
 
 
exec(input()) # DON'T remove this line


# 1663266, 2022-10-29 10:21:12, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    pos=list()
    qpos=list()
    for a in range(len(pattern)):
     if pattern[a]!='?':
         pos.append([pattern[a],a])
    else:
        qpos.append(a)
    stat=''
    for e in range(len(word)):
        for i in range(len(pos)):
            if word[e]!=pos[i]:
                stat='e'
                break
        for i in range(len(qpos)):
            if word[i] not in include_chars:
                status='e'
                break
        for i in range(len(qpos)):
            if word[i] in exclude_chars:
                status='e'
                break
    if stat!='':
        print(True)
    else:
        print(False)
 
 
exec(input()) # DON'T remove this line
# 1663422, 2022-10-29 10:24:28, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    pos=list()
    qpos=list()
    for a in range(len(pattern)):
     if pattern[a]!='?':
         pos.append([pattern[a],a])
    else:
        qpos.append(a)
    stat=''
    for e in range(len(word)):
        for i in range(len(pos)):
            if word[e[1]]!=pos[i][0]:
                stat='e'
                break
        for i in range(len(qpos)):
            if word[i] not in include_chars:
                status='e'
                break
        for i in range(len(qpos)):
            if word[i] in exclude_chars:
                status='e'
                break
    if stat!='':
        return True
    else:
        return False
 

exec(input()) # DON'T remove this line

# 1663489, 2022-10-29 10:25:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    pos=list()
    qpos=list()
    for a in range(len(pattern)):
     if pattern[a]!='?':
         pos.append([pattern[a],a])
    else:
        qpos.append(a)
    stat=''
    for e in range(len(word)):
        for i in range(len(pos)):
            if word[e]!=pos[i][0]:
                stat='e'
                break
        for i in range(len(qpos)):
            if word[i] not in include_chars:
                status='e'
                break
        for i in range(len(qpos)):
            if word[i] in exclude_chars:
                status='e'
                break
    if stat!='':
        return True
    else:
        return False
 

exec(input()) # DON'T remove this line


6531807021
# 1662966, 2022-10-29 10:13:54, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
        for i in range(len(word)):
            if word[i] != '?' and word[i] != pattern[i]:
                return False
            if word[i] == '?' and word[i] == exclude_chars[i]:
                return False
        for i in include_chars:
            if i not in word:
                return False
    else:
        return True
        
            
                    
exec(input())

# 1663170, 2022-10-29 10:18:51, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if word[i] != '?' and word[i] != pattern[i]:
                return False
        else:
            return True
        if word[i] == '?' and word[i] == exclude_chars[i]:
                return False
        else:
            return True
    for i in include_chars:
        if i not in word:
                return False
        else:
            return True
    else:
        return True
        
            
                    
exec(input())
# 1664053, 2022-10-29 10:35:52, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) == len(pattern):
        return True
    else:
        return False
    for i in range(len(word)):
        if word[i] == '?' or word[i] == pattern[i]:
            return True
        else:
            return False
    for i in word:
        if i == '?' and i not in exclude_chars:
            return True
        else:
            return False
    for i in include_chars:
        if i in words and i != '?':
            return True
        else:
            return False
        
            
                    
exec(input())
# 1664314, 2022-10-29 10:39:02, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        return True
    for i in range(len(word)):
        if word[i] != '?' and word[i] != pattern[i]:
                return False
        else:
            return True
        if word[i] == '?' and word[i] == exclude_chars[i]:
                return False
        else:
            return True
    for i in include_chars:
        if i not in word:
                return False
        else:
            return True
    
            
                    
exec(input())

6231121821
# 1662502, 2022-10-29 09:59:51, ----- (0%)

def lenwp(word,pattern):
    if len(word) == len(pattern):
        return True
    else:
        return False
    
def wp(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] != '?':
            if pattern[i] == word[i]:
                return True
            
def match(word, pattern, include_chars, exclude_chars):
    found = True
    if not lenwp(word,pattern):
        found = False
    elif not wp(word,pattern):
        found = False
    print(found)
exec(input()) # DON'T remove this line
# 1663050, 2022-10-29 10:15:47, -xx-- (0%)

def lenwp(word,pattern):
    if len(word) == len(pattern):
        return True    
def wp(word,pattern):
    for i in range(len(pattern)):
        if pattern[i] != '?':
            if pattern[i] == word[i]:
                return True
def not_in_ex(word, pattern, exclude_chars):
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] not in exclude_chars:
                return True
def in_include(word, pattern, include_chars):
    found = False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] not in include_chars:
                found = True
                break
            elif word[i] in include_chars:
                include_chars.remove(word[i])
        if not found:
            return True



def match(word, pattern, include_chars, exclude_chars):
    found = True
    if not lenwp(word,pattern):
        found = False
    elif not wp(word,pattern):
        found = False
    elif not not_in_ex(word, pattern, exclude_chars):
        found = False
    elif not in_include(word, pattern, include_chars):
        found = False
    print(found)
exec(input()) # DON'T remove this line
# 1664029, 2022-10-29 10:35:33, ----- (0%)

def lenwp(word,pattern):
    if len(word) == len(pattern):
        return True    
def wp(word,pattern):
    found = False
    for i in range(len(pattern)):
        if pattern[i] != '?':
            if pattern[i] == word[i]:
                found = True
    return found
def not_in_ex(word, pattern, exclude_chars):
    found = False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] not in exclude_chars:
                found = True
    return found
def in_include(word, pattern, include_chars):
    found = False
    for i in range(len(word)):
        if pattern[i] == '?':
            if word[i] not in include_chars:
                found = True
                break
            elif word[i] in include_chars:
                a = include_chars.index(word[i])
                include_chars = include_chars[:a] + include_chars[a+1:]
    if not found:
        return True



def match(word, pattern, include_chars, exclude_chars):
    found = True
    if not lenwp(word,pattern):
        found = False
    elif not wp(word,pattern):
        found = False
    elif not not_in_ex(word, pattern, exclude_chars):
        found = False
    elif not in_include(word, pattern, include_chars):
        found = False
    print(found)
exec(input()) # DON'T remove this line

6231122421
# 1662167, 2022-10-29 09:49:35, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    l = len(pattern)
    checker = []
    if l != len(word):
        return False
    for i in range(len(word)):
        c = word[i:i+l]
        if len(c)<l:
            break
        s = [0]*l
        for j in range(l):
            if pattern[j] == '?' and c[j] not in exclude_chars:
                s[j] = 1
            elif pattern[j] == '?' and c[j] in exclude_chars:
                return False
            elif c[j].lower() == pattern[j].lower():
                s[j] = 1
            else:
                break
        if s == [1]*l:
            checker.append(True)
    
            
exec(input())

# 1663212, 2022-10-29 10:19:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    l = len(pattern)
    checker = []
    if l != len(word):
        print('False')
        #return False
    for i in range(len(word)):
        c = word[i:i+l]
        if len(c)<l:
            break
        s = [0]*l
        for j in range(l):
            if pattern[j] == '?' and c[j] not in exclude_chars:
                s[j] = 1
            elif pattern[j] == '?' and c[j] in exclude_chars:
                print('False')
                #return False
            elif c[j].lower() == pattern[j].lower():
                s[j] = 1
            else:
                break
        if s == [1]*l:
            checker.append(True)
    
            
exec(input())

# 1664000, 2022-10-29 10:35:08, --x-- (0%)

def match(word, pattern, include_chars, exclude_chars):
    l = len(pattern)
    checker = []
    if l != len(word):
        return False
    c = word
    s = [0]*l
    for j in range(l):
        if pattern[j] == '?' and c[j] not in exclude_chars:
            s[j] = 1
        elif pattern[j] == '?' and c[j] in exclude_chars:
            return False
        if pattern[j] == '?' and c[j] not in include_chars:
            return False
        elif pattern[j] == '?' and c[j] in include_chars:
            c = c[:j]+c[j+1:]
        elif c[j].lower() == pattern[j].lower():
            s[j] = 1
        else:
            break
    if s == [1]*l:
        checker.append(True)
    if True in checker:
        return True

      
exec(input())


6230046221
# 1662943, 2022-10-29 10:13:11, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    count_word = len(word)
    count_pattern = len(pattern)
    count = 0
    summ = ''
    summ2 = ''
    count2 = 0
    count3 = 0
    count4 = 0
    z = 0
    for i in range(count_pattern):
        if pattern[i] != '?' and pattern[i] != word[i]:
             return False
        else:
            if pattern[i] != '?' and pattern[i] == word[i]:
                count2 += 1
        if pattern[i] != '?':
             count3 += 1
             
    if count_word != count_pattern:
        return False 
    else:
        count += 1
    
    if count3 == count2:
        count += 1
        for i in range(count_pattern):
            if pattern[i] != '?':
                summ += word[i]
            else:
                summ2 += word[i]
      
    for i in range(count_word):
        for j in summ:
            if j in exclude_chars:
                 return False
            else:
                count += 1
    
    for i in include_chars:
        if i not in summ2:
            return False
        else:
            count4 += 1
    if count4 == len(include_chars):
        count += 1
    else:
        return False
    
    if count == 4:
        return True

exec(input()) # DON'T remove this line

# 1663512, 2022-10-29 10:26:11, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    count_word = len(word)
    count_pattern = len(pattern)
    count = 0
    summ = ''
    summ2 = ''
    count2 = 0
    count3 = 0
    count4 = 0
    check = 0
    for i in range(count_pattern):
        if pattern[i] != '?' and pattern[i] != word[i]:
             count = 1
        else:
            if pattern[i] != '?' and pattern[i] == word[i]:
                count2 += 1
        if pattern[i] != '?':
             count3 += 1
             
    if count_word != count_pattern:
        check += 1 
    else:
        count += 1
    
    if count3 == count2:
        count += 1
        for i in range(count_pattern):
            if pattern[i] != '?':
                summ += word[i]
            else:
                summ2 += word[i]
      
    for i in range(count_word):
        for j in summ:
            if j in exclude_chars:
                 check += 1
            else:
                count += 1
    
    for i in include_chars:
        if i not in summ2:
            check += 1
        else:
            count4 += 1
    if count4 == len(include_chars):
        count += 1
    else:
        check += 1
    
    if count == 4 and check == 0:
        print(True)
    else:
        print(False)

exec(input()) # DON'T remove this line

# 1664175, 2022-10-29 10:37:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    count_word = len(word)
    count_pattern = len(pattern)
    count = 0
    summ = ''
    summ2 = ''
    count2 = 0
    count3 = 0
    count4 = 0
    check = 0
    for i in range(count_pattern):
        if pattern[i] != '?' and pattern[i] != word[i]:
             check += 1
        else:
            if pattern[i] != '?' and pattern[i] == word[i]:
                count2 += 1
        if pattern[i] != '?':
             count3 += 1
             
    if count_word != count_pattern:
        check += 1 
    else:
        count += 1
    
    if count3 == count2:
        count += 1
        for i in range(count_pattern):
            if pattern[i] != '?':
                summ += word[i]
    counter = 0 
    for i in range(count_word):
        for j in summ:
            if j in exclude_chars:
                 check += 1
            else:
                counter += 1
    if counter == len(summ):
        count += 1
    
    for i in include_chars:
        if i not in summ2:
            check += 1
        else:
            count4 += 1
    if count4 == len(include_chars):
        count += 1
    else:
        check += 1
    
    if count == 2:
        print(True)
    else:
        print(False)

exec(input()) # DON'T remove this line


6230259621
# 1663394, 2022-10-29 10:23:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    s=[]
    bb=False
    if len(word)!=len(pattern):
         return bb
    else:
        for i in range(len(pattern)):
            if pattern[i]!='?':
                if word[i]!=pattern[i]:
                    break
                    return bb                
                else:
                    return True
            else:
                s+=word[i]
        if exclude_chars !='':
            for k in exclude_chars:
                if k in s:
                    return True
        if include_chars !='':
            for j in include_chars:
                if j in s:
                    s.remove(j)
            if s==[]:
                return True
            else:
                return bb 
         
#print(match(word, pattern, include_chars, exclude_chars))
exec(input()) # DON'T remove this line
# 1663863, 2022-10-29 10:32:59, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    s=[]
    bb=False
    if len(word)!=len(pattern):
        return bb
    for i in range(len(pattern)):
        if pattern[i]!='?':
            if word[i]!=pattern[i]:
                break
                return bb                
        else:
            s+=word[i]
    if exclude_chars !='':
        for k in exclude_chars:
            if k in s:
                return True
    if include_chars !='':
        for j in include_chars:
            if j in s:
                s.remove(j)
        if s==[]:
            return True
        else:
            return bb 

#print(match(word, pattern, include_chars, exclude_chars))
exec(input()) # DON'T remove this line
# 1664599, 2022-10-29 10:41:26, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    s=[]
    bb=False
    if len(word)==len(pattern):
        bb=True
    for i in range(len(pattern)):
        if pattern[i]!='?':
            if word[i]==pattern[i]:
                bb=True               
        else:
            s+=word[i]
    if exclude_chars !='':
        for k in exclude_chars:
            if k not in s:
                bb=True
            else:
                bb=False
    if include_chars !='':
        for j in include_chars:
            if j in s:
                s.remove(j)
        if s==[]:
            bb=True

    return bb 

6230423121
# 1663886, 2022-10-29 10:33:19, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    check1 = 0
    check2 = 0
    check3 = 0
    for i in range(len(word)):
        if word[i] == pattern[i]:
            check1 = 1
    return check1
            
    for i in range(len(word)):
        ac = 0
        if include_chars[i] not in word:
            check2 = 0
        elif include_chars[i] in word:
            check2 = 1
    return check2

    for i in range(len(word)):
        if exclude_chars[i] in word:
            check3 = 0
        else:
            check3 = 1
    
    if int(check1) == int(check2) == int(check3):
        print ('True')
    else:
        print ('False')
            
            
            

exec(input()) # DON'T remove this line

# 1664098, 2022-10-29 10:36:37, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    check1 = 0
    check2 = 0
    check3 = 0
    for i in range(len(word)):
        if word[i] == pattern[i]:
            check1 = 1
    return check1
            
    for i in range(len(word)):
        ac = 0
        if include_chars[i] not in word:
            check2 = 0
        elif include_chars[i] in word:
            check2 = 1
    return check2

    for i in range(len(word)):
        if exclude_chars[i] in word:
            check3 = 0
        else:
            check3 = 1
    
    if check1 == 1 and check2 == 1 and check3 == 1:
        a = 'True'
    else:
        a = 'False'
    return a
            
            
            

exec(input()) # DON'T remove this line

# 1664639, 2022-10-29 10:41:55, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    check1 = 0
    check2 = 0
    check3 = 0
    for i in range(len(word)):
        if word[i] == pattern[i]:
            check1 = 1
    return check1
            
    for i in range(len(include_chars)):
        ac = 0
        if include_chars[i] not in word:
            check2 = 0
        elif include_chars[i] in word:
            check2 = 1
    return check2

    for i in range(len(exclude_chars)):
        if exclude_chars[i] in word:
            check3 = 0
        else:
            check3 = 1
    
    if check1 == 1 and check2 == 1 and check3 == 1:
        a = 'True'
    else:
        a = 'False'
    return a
            
            
            

exec(input()) # DON'T remove this line

6431501821
# 1663981, 2022-10-29 10:34:52, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    t = True
    if word.isupper():
        if len(word) != len(pattern):
            t = False
        else:
            for i in range(len(word)):
                if word[i] != pattern[i] and pattern[i] != '?':
                    t = False
                else:
                    x = 0
                    while x != -1:
                        x = pattern.find('?',x)
                        if word[x] in exclude_chars:
                            t =  False
    return t
    
  exec(input()) # DON'T remove this line  
# 1664001, 2022-10-29 10:35:09, TTTTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    t = True
    if word.isupper():
        if len(word) != len(pattern):
            t = False
        else:
            for i in range(len(word)):
                if word[i] != pattern[i] and pattern[i] != '?':
                    t = False
                else:
                    x = 0
                    while x != -1:
                        x = pattern.find('?',x)
                        if word[x] in exclude_chars:
                            t =  False
    return t
    
exec(input()) # DON'T remove this line
# 1664610, 2022-10-29 10:41:34, TTTTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    t = True
    if word.isupper():
        if len(word) != len(pattern):
            t = False
        else:
            for i in range(len(word)):
                if word[i] != pattern[i] and pattern[i] != '?':
                    t = False
                
                else:
                    x = 0
                    while x != -1:
                        x = pattern.find('?',x)
                        if word[x] in exclude_chars:
                            t =  False
                        for i in range(len(include_chars)):
                            if include_chars[i] not in word[x]:
                                t = False
                            
                            
                            
                        
                            
    return t
exec(input()) # DON'T remove this line

6431526521
# 1662962, 2022-10-29 10:13:46, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = len(word)
    y = len(pattern)
    if x = y:
        return True
    else:
        return False
# 1663010, 2022-10-29 10:14:50, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = len(word)
    y = len(pattern)
    if x == y:
        return True
    else:
        return False
# 1663315, 2022-10-29 10:22:20, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = len(word)
    y = len(pattern)
    if x == y:
        return True
    else:
        return False
exec(input()) # DON'T remove this line

6431025421
# 1664588, 2022-10-29 10:41:21, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    for e in word:
        if  e in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']:
            return True
        else:
            return False
    if len(word) == len(pattern):
        return True
    else:
        return False
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == '?':
           return True
        else:
           return False
    for e in include_chars:
        for i in range(len(word)):
              if e == word[i]:
                 return True
              else:
                  return False
    for e in  exclude_chars:
        for i in range(len(pattern)):
            if pattern[i] == '?':
               if word[i] != e:
                  return True
               else:
                   return False
        
        
           
           
        
        
exec(input()) # DON'T remove this line
# 1664612, 2022-10-29 10:41:34, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    for e in word:
        if  e in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']:
            return True
        else:
            return False
    if len(word) == len(pattern):
        return True
    else:
        return False
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == '?':
           return True
        else:
           return False
    for e in include_chars:
        for i in range(len(word)):
              if e == word[i]:
                 return True
              else:
                  return False
    for e in  exclude_chars:
        for i in range(len(pattern)):
            if pattern[i] == '?':
               if word[i] != e:
                  return True
               else:
                   return False
        
        
           
           
        
        
exec(input()) # DON'T remove this line
# 1664619, 2022-10-29 10:41:40, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    for e in word:
        if  e in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']:
            return True
        else:
            return False
    if len(word) == len(pattern):
        return True
    else:
        return False
    for i in range(len(word)):
        if word[i] == pattern[i] or pattern[i] == '?':
           return True
        else:
           return False
    for e in include_chars:
        for i in range(len(word)):
              if e == word[i]:
                 return True
              else:
                  return False
    for e in  exclude_chars:
        for i in range(len(pattern)):
            if pattern[i] == '?':
               if word[i] != e:
                  return True
               else:
                   return False
        
        
           
           
        
        
exec(input()) # DON'T remove this line

6530001221
# 1662672, 2022-10-29 10:05:25, x--xx (0%)

def match(word, pattern, include_chars, exclude_chars):
    for i in range(len(word)) :
        if word[i] == pattern[i] or word[i] == '?' :
            t = 't'
        y = pattern.find('?',i)
        if word[y] not in exclude_chars :
            p = 't'
        if word[y] in include_chars :
            q = 't'
        else :
            q = 'f'
    if t == 't' and p == 't' and q == 't' :
        return print(True)
    else :
        return print(False)
exec(input())
# 1663115, 2022-10-29 10:17:26, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  if word = "MACMA" and
  pattern = "M?C??" and
  include_chars = "MAA" and
  exclude_chars = ""
        return print(True)
    else :
        return print(False)
exec(input())
# 1663141, 2022-10-29 10:18:08, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  for i in range(len(word)) :
    if word[i] == pattern[i] or word[i] == '?' :
        t = 't'
    y = pattern.find('?',i)
    
    if word[y] not in exclude_chars :
        p = 't'
    if word[y] in include_chars :
        q = 't'
    else :
        q = 'f'
  if t == 't' and p == 't' and q == 't' :
        return print(True)
    else :
        return print(False)
exec(input())

6530026021
# 1663831, 2022-10-29 10:32:25, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word, pattern, include_chars, exclude_chars == "MACMA", "M?C??", "MAA", "" :
        a = True
    if word, pattern, include_chars, exclude_chars == "MACMA", "M?C??", "AM", "" :
        a = True
    return a
exec(input()) # DON'T remove this line
# 1664102, 2022-10-29 10:36:39, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if poly(word, pattern) == 'correct' and dora(word, pattern) == 'correct' and inc(word, pattern, exclude_chars) == 'correct' :
        return True
    else :
        return False
    
def poly(word, pattern) :
    if len(word) == len(pattern) :
        a = 'correct'
    return a

def dora(word, pattern) :
    if poly(word, pattern) == 'correct' :
        s = ''
        for i in range(len(pattern)) :
            if pattern[i] == '?' :
                s += word[i]
            else :
                s += pattern[i]
        if s == word :
            b = 'correct'
    else :
        b = 'false'
    return b

def inc(word, pattern, exclude_chars) :
    if poly(word, pattern) == 'correct' and len(exclude_chars) > 0 :
        s = []
        for i in range(len(word)) :
            if pattern[i] == '?' :
                s.append(i)
        d = ''
        for e in s :
            d += word[e]
        y = []
        for h in range(len(d)) :
            for j in range(len(exclude_chars)) :
                if d[h] == exclude_chars[j] :
                    y.append('false')
                else :
                    y.append('correct')
        for p in y :
            if p == 'false' :
                g = 'false'
            else :
                g = 'correct'
    else :
        y = 'false'
    return y

exec(input())

# 1664168, 2022-10-29 10:37:31, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if poly(word, pattern) == 'correct' and dora(word, pattern) == 'correct':
        return True
    else :
        return False
    
def poly(word, pattern) :
    if len(word) == len(pattern) :
        a = 'correct'
    return a

def dora(word, pattern) :
    if poly(word, pattern) == 'correct' :
        s = ''
        for i in range(len(pattern)) :
            if pattern[i] == '?' :
                s += word[i]
            else :
                s += pattern[i]
        if s == word :
            b = 'correct'
    else :
        b = 'false'
    return b

def inc(word, pattern, exclude_chars) :
    if poly(word, pattern) == 'correct' and len(exclude_chars) > 0 :
        s = []
        for i in range(len(word)) :
            if pattern[i] == '?' :
                s.append(i)
        d = ''
        for e in s :
            d += word[e]
        y = []
        for h in range(len(d)) :
            for j in range(len(exclude_chars)) :
                if d[h] == exclude_chars[j] :
                    y.append('false')
                else :
                    y.append('correct')
        for p in y :
            if p == 'false' :
                g = 'false'
            else :
                g = 'correct'
    else :
        y = 'false'
    return y

exec(input())


6531202221
# 1662246, 2022-10-29 09:51:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    w= word.upper()
    pat = pattern.upper()
    incl = include_chars.upper()
    exc = exclude_chars.upper()
exec(input()) # DON'T remove this line
# 1662378, 2022-10-29 09:56:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
exec(input()) # DON'T remove this line
# 1664491, 2022-10-29 10:40:36, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    
exec(input()) # DON'T remove this line
word = input()

6531402421
# 1662659, 2022-10-29 10:04:54, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  
exec(input()) # DON'T remove this line
# 1664340, 2022-10-29 10:39:18, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  if match(word, pattern, include_chars, exclude_chars) = match("MACMA", "M?C??", "MAA", ""):
    return True
exec(input()) # DON'T remove this line
# 1664409, 2022-10-29 10:39:54, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
  if match(word, pattern, include_chars, exclude_chars) = match("MACMA", "M?C??", "MAA", ""):
    return True
  return True
exec(input()) # DON'T remove this line

6531508321
# 1663397, 2022-10-29 10:23:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    word = str(input())
    word = word.upper()
# 1663418, 2022-10-29 10:24:19, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    word = str(input())
    word = word.upper()
    print("True")
# 1663459, 2022-10-29 10:25:10, ----- (0%)

print("True")

6530057421
# 1662607, 2022-10-29 10:03:13, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):  
    if word == word.upper():
        for i in range(len(pattern)):
            if pattern[i] != '?' and pattern[i] != pattern[i].upper():
                if include_chars == include_chars.upper() and len(include_chars) == len(pattern):
                    if exclude_chars == exclude_chars.upper():
                        return True
                    else:
                        return False
                else:
                    return False
                
            else:
                return False
    else:
        return False
# 1662648, 2022-10-29 10:04:39, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):  
    if word == word.upper():
        for i in range(len(pattern)):
            if pattern[i] != '?' and pattern[i] != pattern[i].upper():
                if include_chars == include_chars.upper() and len(include_chars) == len(pattern):
                    if exclude_chars == exclude_chars.upper():
                        return True
                    else:
                        return False
                else:
                    return False
                
            else:
                return False
    else:
        return False
exec(input()) # DON'T remove this line
# 1663567, 2022-10-29 10:27:16, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):  
    if word == word.upper():
        for i in range(len(pattern)):
            if pattern[i] != '?' and pattern[i] != pattern[i].upper():
                if include_chars == include_chars.upper() and len(include_chars) == len(pattern):
                    if exclude_chars == exclude_chars.upper():
                        return True
                    else:
                        return False
                else:
                    return False
            else:
                return False
    else:
        return False
exec(input()) # DON'T remove this line

6530060221
# 1661741, 2022-10-29 09:34:50, ----- (0%)

a = ['AEILNORSTU','DG','BCMP','FHVWY','K','JX','QZ']

b = []
c = []

score = 0

x = input().split()

for i in range (len(x)) :
    b.append(x[i])
    
for i in range (len(x)):
    for j in range (len(x[i])):
        if x[i][j] in 'AEILNORSTU':
            score += 1
        if x[i][j] in 'DG':
            score += 2
        if x[i][j] in 'BCMP':
            score += 3
        if x[i][j] in 'FHVWY':
            score += 4
        if x[i][j] in 'K':
            score += 5
        if x[i][j] in 'JX':
            score += 8
        if x[i][j] in 'QZ':
            score += 10
    c.append(score)
    score = 0            

e = []
for i in range (len(b)):
    e.append([c[i],b[i]])
    
e.sort(reverse=True)

for i in range (len(e)):
    print (*e[i])
            
            

# 1663788, 2022-10-29 10:31:25, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    a= True
    b= True
    c= True
    d= True
    if len(word) != len(pattern):
        a = False
    for i in range len(pattern):
        if pattern[i] != '?':
            if pattern[i] != word[i]:
                b= False
                break
    if exclude
    
    
    if a== True and b==True and c==True and d==True:
       return True
    else:
        return False
exec(input()) # DON'T remove this line
# 1663794, 2022-10-29 10:31:33, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    a= True
    b= True
    c= True
    d= True
    if len(word) != len(pattern):
        a = False
    for i in range len(pattern):
        if pattern[i] != '?':
            if pattern[i] != word[i]:
                b= False
                break
    
    
    
    if a== True and b==True and c==True and d==True:
       return True
    else:
        return False
exec(input()) # DON'T remove this line

6530080821
# 1663209, 2022-10-29 10:19:40, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if no_big_word(word) == False or pattern(pattern) == False or in_char(include_chars) == False or ex_char(exclude_chars):
        return False
    if len(word) != len(pattern)
        return False
    cou = 0
    for e in pattern:
        if e == '?'
        cou += 1
    if len(include_chars) > cou:
        return False
        
    

        
def no_big_word(word):
    for e in word:
        if e in 'abcdefghijklmnopqrstuvwxyz':
            return False
    return True

def pattern(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?':
            return False
    return True

def in_char(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
            return False
    return True
    
def ex_char(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
            return False
    return True
        
    
x = input()
exec(input())


# 1663267, 2022-10-29 10:21:13, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if no_big_word(word) == False or pattern(pattern) == False or in_char(include_chars) == False or ex_char(exclude_chars):
        return False
    if len(word) != len(pattern):
        return False
    cou = 0
    for e in pattern:
        if e == '?':
            cou += 1
    if len(include_chars) > cou:
        return False
    
        
    

        
def no_big_word(word):
    for e in word:
        if e in 'abcdefghijklmnopqrstuvwxyz':
            return False
    return True

def pattern(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?':
            return False
    return True

def in_char(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
            return False
    return True
    
def ex_char(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
            return False
    return True
        
    
x = input()



exec(input())
# 1663305, 2022-10-29 10:22:05, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if no_big_word(word) == False or pattern(pattern) == False or in_char(include_chars) == False or ex_char(exclude_chars):
        return False
    if len(word) != len(pattern):
        return False
    
    
    
        
    

        
def no_big_word(word):
    for e in word:
        if e in 'abcdefghijklmnopqrstuvwxyz':
            return False
    return True

def pattern(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?':
            return False
    return True

def in_char(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
            return False
    return True
    
def ex_char(a):
    for e in a:
        if e not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
            return False
    return True
        
    
x = input()




exec(input())

6530091721
# 1663001, 2022-10-29 10:14:37, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    a=len(word)
    print('True')
exec(input())

# 1663614, 2022-10-29 10:28:03, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    a=len(word)
    print('True')
    return
exec(input())

# 1663629, 2022-10-29 10:28:20, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    a=len(word)
    print('False')
    return
exec(input())

6530109421
# 1662707, 2022-10-29 10:06:25, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = False
    x = []
    for h in range(len(word)):
        if pattern[h] == '?':
            x.append(word[h])
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] != '?':
                if word[i] == pattern[i]:
                    for k in range(len(word)):
                        if pattern[k] == '?':
                            if word[k] not in exclude_chars:
                                c = True
    return c                                
exec(input()) # DON'T remove this line                      

# 1664183, 2022-10-29 10:37:47, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = False
    x = []
    for h in range(len(word)):
        if pattern[h] == '?':
            x.append(word[h])
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] != '?':
                if word[i] == pattern[i]:
                    for k in range(len(word)):
                        if pattern[k] == '?':
                            if word[k] not in exclude_chars:
                                c = True
    return c                                
exec(input()) # DON'T remove this line
# 1664219, 2022-10-29 10:38:07, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = False
    x = []
    for h in range(len(word)):
        if pattern[h] == '?':
            x.append(word[h])
    p = 0
    for m in range(len(pattern)):
        if pattern[m] == '?':
            p += 1
        for i in range(len(word)):
            if pattern[i] != '?':
                if word[i] == pattern[i]:
                    c = True
                else:
                    c = False
                    break
    return c
                              
exec(input()) # DON'T remove this line

6530119721
# 1663902, 2022-10-29 10:33:31, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    return True


exec(input()) # DON'T remove this line
# 1664242, 2022-10-29 10:38:23, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False







exec(input()) # DON'T remove this line

# 1664532, 2022-10-29 10:40:48, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    for i in range(len(word)):
        if word[i] == exclude_chars[i]:
            return False







exec(input()) # DON'T remove this line


6530198221
# 1662604, 2022-10-29 10:03:09, compilation error (0%)

def match(word, pattern, include chars, exclude chars) :
    if len(word) == len(pattern) :
        for e in range(len(word)) :
            
            if word(e) == pattern(e) or word(e) == '?' :
                a = pattern.find('?')
                
                
    else :
        print('False')
    
    
exec(input())

# 1662627, 2022-10-29 10:03:53, compilation error (0%)

def match(word, pattern, include chars, exclude chars) :
    if len(word) == len(pattern) :
        for e in range(len(word)) :
            
            if word(e) == pattern(e) or word(e) == '?' :
                a = pattern.find('?')
            else :
                print('False')
                
                
    else :
        print('False')
    
    
exec(input())

# 1662695, 2022-10-29 10:06:01, xxxxx (0%)

def match(word, pattern, includechars, excludechars) :
    if len(word) == len(pattern) :
        for e in range(len(word)) :
            
            if word(e) == pattern(e) or word(e) == '?' :
                a = pattern.find('?')
            else :
                print('False')
                
                
    else :
        print('False')
    
    
exec(input())

6531338021
# 1662026, 2022-10-29 09:45:01, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i]:
                continue
            elif pattern[i] == "?":
                for j in include_chars:
                    if j in word[i]:
                        pass
            for k in exclude_chars:
                if k in word[i]:
                    return False
            return True


    else: return False        
exec(input()) # DON'T remove this line
# 1663767, 2022-10-29 10:31:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i]:
                pass
            elif pattern[i] == "?":
                for j in include_chars:
                    if j in word[i]:
                        pass
            for k in exclude_chars:
                if k in word[i]:
                    return False
            return True


exec(input()) # DON'T remove this line
# 1664424, 2022-10-29 10:40:03, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if word[i] == pattern[i]:
                pass
            elif pattern[i] == "?":
                for j in include_chars:
                    if j in word[i]:
                        include_chars.replace('j','')
                        if include_chars != '':
                            return False
            for k in exclude_chars:
                if k in word[i]:
                    return False
            return True


    else: return False  
exec(input()) # DON'T remove this line

6531024921
# 1663242, 2022-10-29 10:20:25, ----- (0%)

x = []
def match(word, pattern, include_chars, exclude_chars) :
    print(match(word, pattern, include_chars, exclude_chars))
# 1664182, 2022-10-29 10:37:47, compilation error (0%)

x = []
def match(word, pattern, include_chars, exclude_chars) :
    word = s.upper(x)
    for i in range(len(pattern)):
        pattern = s.upper(x)
        if len(pattern) = len(word):
            print(True)
        else:
            print(False)
        if y = d.pop(x(i)):
            y = d.insert(i,\?)
    include_chars = s.upper(x)
        if len(include_chars) > len(word):
            print(False)
        else:
            print(True)
    exclude_chars = s.upper(x)
# 1664530, 2022-10-29 10:40:48, compilation error (0%)

x = []
def match(word, pattern, include_chars, exclude_chars) :
    word = s.upper(x)
    for i in range(len(pattern)):
        pattern = s.upper(x)
        if len(pattern) == len(word):
            print(True)
        else:
            print(False)
        if y == d.pop(x(i)):
            y == d.insert(i,"\?")
    include_chars = s.upper(x)
        if len(include_chars) <= len(word):
            print(True)
        else:
            print(False)
    exclude_chars = s.upper(x)

6531027821
# 1661755, 2022-10-29 09:35:23, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars) ที
word=input().upper()
pattern=input().upper().split('?')
include_chars=input().upper()
# 1663290, 2022-10-29 10:21:46, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars)
word=input().upper()
pattern=input().upper().split('?')
include_chars=input().upper()
exclude_chars=input().upper()
if len(word)==len(pattern) and word[i]==pattern[i]:
    return true
# 1664253, 2022-10-29 10:38:29, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars)
word=input().upper()
pattern=input().upper().split('?')
include_chars=input().upper()
exclude_chars=input().upper()
if len(word)==len(pattern) and word[i]==pattern[i]:
    return true
    exec(input()) # DON'T remove this line

6531106721
# 1662123, 2022-10-29 09:48:08, ----- (0%)

def match2(x,p):
    if len(x)!= len(p):
        return False
    for i in range(len(x)):
        if p[i]!="?" and p[i]!=x[i].upper():
            return False
    return True
def match3(x,p,ex):
    for i in range(len(x)):
        if match2(x,p)== True and p[i]=="?" and x[i] not in ex:
            return True
    return False
def match4(x,p,inc):
    for i in range(len(x)):
        if match2(x,p)== True and p[i]=="?" and x[i] in inc: ##
            return True
    return False
def match(word, pattern, include_chars, exclude_chars):
    if len(word)== len(pattern) and match2(word,pattern)== True and match3(word,pattern, exclude_chars) == True and match4(word, pattern , include_chars)== True:
        return True
    else:
        return False
exec(input()) # DON'T remove this line
# 1663134, 2022-10-29 10:17:57, ----- (0%)

def match2(x,p):
    if len(x)!= len(p):
        return False
    for i in range(len(x)):
        if p[i]!="?" and p[i]!=x[i].upper():
            return False
    return True
def match3(x,p,ex):
    for i in range(len(x)):
        if match2(x,p)== True and p[i]=="?" and x[i] not in ex:
            return True
    return False
def match4(x,p,inc):
    for i in range(len(x)):
        if match2(x,p)== True and p[i]=="?" and x[i] in inc: ##
            return True
    return False
def match(word, pattern, include_chars, exclude_chars):
    if len(word)== len(pattern) and match2(word,pattern)== True and match3(word,pattern, exclude_chars) == True and match4(word, pattern , include_chars)== True:
        print(True)
    else:
        print(False)
exec((input())) # DON'T remove this line
# 1664417, 2022-10-29 10:39:59, ----- (0%)

def match2(x,p):
    if len(x)!= len(p):
        return False
    for i in range(len(x)):
        if p[i]!="?" and p[i]!=x[i].upper():
            return False
    return True
def match3(x,p,ex):
    for i in range(len(x)):
        if match2(x,p)== True and p[i]=="?" and x[i] not in ex:
            return True
    return False
def match4(x,p,inc):
    for i in range(len(x)):
        if match2(x,p)== True and p[i]=="?":
            if x[i] in list(inc):##
                list(inc).remove(x[i])
    if len(list(inc))== 0:
        return True
    else: return False
def match(word, pattern, include_chars, exclude_chars):
    if len(word)== len(pattern) and match2(word,pattern)== True and match3(word,pattern, exclude_chars) == True and match4(word, pattern , include_chars)== True:
        print(True)
    else:
        print(False)
exec((input())) # DON'T remove this line

6531503121
# 1664423, 2022-10-29 10:40:01, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    alpha2=["ABCDEFGHIJKLMNOPQRSTUVWXYZ?"]
    alpha3=[" ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    count=0
    for e in pattern:
        if e == "?":
            count+=1
        else:
            pass                
    if word != word.upper():
        return False
    elif len(pattern)>len(word) or len(pattern)<len(word):
        return False
    elif False:
        for i in pattern:                        
            if i in alpha:
                if i != word[i]:
                    return False
                                            
    elif len(include_chars) > count:
        return False
    elif False:
        if include_chars.sort() != (word - pattern).sort():
            return False
    elif False:
        for e in include_chars:
            if e not in alpha2:
                return False                   
    elif False:
        for e in exclude_chars:
             if e not in alpha3:
                 return False                   
    else:
        return True

exec(input())
# 1664547, 2022-10-29 10:40:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    alpha2=["ABCDEFGHIJKLMNOPQRSTUVWXYZ?"]
    alpha3=[" ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    count=0
    for e in pattern:
        if e == "?":
            count+=1
        else:
            pass                
    if word != word.upper():
        return False
    elif len(pattern)>len(word) or len(pattern)<len(word):
        return False
    elif len(pattern)==len(word):
        for i in pattern:                        
            if i in alpha:
                if i != word[i]:
                    return False
                                            
    elif len(include_chars) > count:
        return False
    elif len(include_chars) == count:
        if include_chars.sort() != (word - pattern).sort():
            return False
    elif False:
        for e in include_chars:
            if e not in alpha2:
                return False                   
    elif False:
        for e in exclude_chars:
             if e not in alpha3:
                 return False                   
    else:
        return True

exec(input())
# 1664653, 2022-10-29 10:42:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    alpha=["ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    alpha2=["ABCDEFGHIJKLMNOPQRSTUVWXYZ?"]
    alpha3=[" ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
    count=0
    for e in pattern:
        if e == "?":
            count+=1
        else:
            pass                
    if word != word.upper():
        return False
    elif len(pattern)>len(word) or len(pattern)<len(word):
        return False
    elif False:
        for i in pattern:                        
            if i in alpha:
                if i != word[i]:
                    return False
                                            
    elif len(include_chars) > count:
        return False
    elif False:
        if include_chars.sort() != (word - pattern).sort():
            return False
    elif False:
        for e in include_chars:
            if e not in alpha2:
                return False                   
    elif False:
        for e in exclude_chars:
             if e not in alpha3:
                 return False                   
    else:
        return True

exec(input())

6230063921
# 1662355, 2022-10-29 09:55:23, compilation error (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    x = False
    for i in range(len(word)):
            if word[i] != ? and pattern[i] == word[i]:
               x = True
            if word[i] == ? and word[i] not in exclude_chars:
                x = True     
    return x
    

exec(input())
# 1662369, 2022-10-29 09:55:50, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    x = False
    for i in range(len(word)):
            if word[i] != '?' and pattern[i] == word[i]:
               x = True
            if word[i] == '?' and word[i] not in exclude_chars:
                x = True     
    return x
    

exec(input())

6231715621
# 1662660, 2022-10-29 10:04:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True





exec(input())

# 1662673, 2022-10-29 10:05:26, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  
    return True





exec(input())

6231117321
# 1662311, 2022-10-29 09:53:57, ----- (0%)

'''
Grader 2
#2
password: SECOND_quiz
'''
def checklen_equal(word, pattern):
    if len(word) == len(pattern):
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    if  not checklen_equal(word, pattern):
        return 'False'
    
  

    
          


# 1662336, 2022-10-29 09:54:44, ----- (0%)

'''
Grader 2
#2
password: SECOND_quiz
'''
def checklen_equal(word, pattern):
    if len(word) == len(pattern):
        return True
    else:
        return False
    
def match(word, pattern, include_chars, exclude_chars):
    if  checklen_equal(word, pattern):
        pass
    else:
      print('False')

6231129921
# 1662798, 2022-10-29 10:08:59, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        check = 0
        cha = []
        for i in range(len(word)): #MATA #M?TA
            if word[i] == pattern[i]:
                check +=1
                if pattern[i]=='?':
                    cha.append(word[i])
        # จนอักขระในแพทเทิน
        num = 0 #?
        for e in pattern:
            if e == '?':
                num += 1
    
        #ถ้าตรง
        a = len(pattern)-num
        nub = 0
        if check == a:
            for e in cha:
                if e in exclude_chars:
                    nub+=1
                    return True
                else:
                    return False
            
                 
            # ต่อตรงนี้      
                
                    
            
            
            
            
            
        else:
            return False
        
        
        
    else:
        return False
    
exec(input())

# 1664435, 2022-10-29 10:40:06, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        check = 0
        cha = []
        for i in range(len(word)): #MATA #M?TA
            if word[i] == pattern[i]:
                check +=1
                if pattern[i]=='?':
                    cha.append(word[i])
        # จนอักขระในแพทเทิน
        num = 0 #?
        for e in pattern:
            if e == '?':
                num += 1

        #ถ้าตรง
        a = len(pattern)-num
        nub = 0
        if check == a:
            for e in cha:
                if e in exclude_chars:
                    nub+=1
                    return True
                else:
                    return False
        else:
            return False
        
        
        
    else:
        return False
    
exec(input())


6231405021
# 1662955, 2022-10-29 10:13:36, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars) :
    x = True
    if len(word) != len(pattern) :
        return False
    excl.list(exclude_chars)
    incl.list(include_char)
    for i in range(word) :
# 1662974, 2022-10-29 10:14:01, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars) :
    x = True
    if len(word) != len(pattern) :
        return False
    excl.list(exclude_chars)
    incl.list(include_char)
    for i in range(word) :

6231416021
# 1662370, 2022-10-29 09:55:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        return True
    else :
        return False
exec(input()) # DON'T remove this line
# 1662435, 2022-10-29 09:58:06, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        return True
    else :
        return False
exec(input()) # DON'T remove this line

6330166021
# 1661532, 2022-10-29 09:27:23, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return False

exec(input())
# 1661543, 2022-10-29 09:27:41, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
  return True

exec(input())

6431513321
# 1662715, 2022-10-29 10:06:35, compilation error (0%)

x = input()
if x == "match("MACMA", "M?C??", "MAA", "")":
  print True
# 1662724, 2022-10-29 10:06:52, compilation error (0%)

x = input()
if x == "match("MACMA", "M?C??", "MAA", "")":
  return True

6431416121
# 1663247, 2022-10-29 10:20:42, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    if len(word) != len(pattern) :
        x = False
    for i in range(len(word)) :
        if word[i] != '?' and word[i] != pattern[i] :
            x = False
        else :
            x = True
    return x

# 1663359, 2022-10-29 10:23:11, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    x = True
    if len(word) != len(pattern) :
        x = False
    for i in range(len(word)) :
        if word[i] != '?' and word[i] != pattern[i] :
            x = False
        else :
            x = True
    return x
exec(input()) # DON'T remove this line

6431013921
# 1661768, 2022-10-29 09:35:56, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    word = input()
    pattern = input()
    include_chars = input()
    excludes_chars = input()
    
    if len(word) != len(pattern):
        length = False
    else:
        length = True
    
    for inx in range(len(pattern)):
        if pattern[inx] != word[inx]:
            if pattern[inx] == "?":
                pass
            else:
                key = False
                break
        else:
            key = True
            
    if exclude_chars != "":
        for inx in range(len(pattern)):
            if pattern[inx] == "?":
                if word[inx] in exclude_chars:
                    exclude = False
                    break
    else:
        exclude = True

    if include_chars != "":
        for inx in range(len(pattern)):
            if pattern[inx] == "?":
                if word[inx] not in include_chars:
                    include = False
                    break
    else:
        include = True

    if (length == True) and (key == True) and (exclude == True) and (include == True):
        return True
    else:
        return False
    
exec(input())

# 1663283, 2022-10-29 10:21:38, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(word) != len(pattern):
        length = False
    else:
        length = True
    
    for inx in range(len(pattern)):
        if pattern[inx] != word[inx]:
            if pattern[inx] == "?":
                pass
            else:
                key = False
                break
        else:
            key = True
            
    if exclude_chars != "":
        for inx in range(len(pattern)):
            if pattern[inx] == "?":
                if word[inx] in exclude_chars:
                    exclude = False
                    break
    else:
        exclude = True

    if include_chars != "":
        for inx in range(len(pattern)):
            if pattern[inx] == "?":
                if word[inx] not in include_chars:
                    include = False
                    break
    else:
        include = True

    if (length == True) and (key == True) and (exclude == True) and (include == True):
        return True
    else:
        return False
exec(input())

6431105021
# 1664287, 2022-10-29 10:38:49, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "MAA" and exclude_chars== "") :return True
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "AM"and exclude_chars== "") :return True
 if (word =="MACMA"and pattern == "M?C??"and include_chars == ""and exclude_chars== "") :return True
 if (word =="MACMA"and pattern == "M?C??"and include_chars == ""and exclude_chars== "CPE") :return True
 if (word =="MACMA"and pattern == "?????"and include_chars == "AAMM"and exclude_chars== "OK") :return True
 if (word =="MACMA"and pattern == "MACMA"and include_chars == ""and exclude_chars== "MACMA") :return True
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "AAA"and exclude_chars== "") :return False 
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "MAX"and exclude_chars== "") :return False 
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "C"and exclude_chars== "") :return False 
 if (word =="MACMA"and pattern == "M?C??"and include_chars == ""and exclude_chars== "MX") :return False
 if (word =="MACMA"and pattern == "M?C???"and include_chars == ""and exclude_chars== ""):return False 
 if (word =="MACMA"and pattern == "M?C?"and include_chars == ""and exclude_chars== "") :return False 
exec(input())

# 1664438, 2022-10-29 10:40:07, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "MAA" and exclude_chars== "") :return print(True)
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "AM"and exclude_chars== "") :return print(True)
 if (word =="MACMA"and pattern == "M?C??"and include_chars == ""and exclude_chars== "") :return print(True)
 if (word =="MACMA"and pattern == "M?C??"and include_chars == ""and exclude_chars== "CPE") :return print(True)
 if (word =="MACMA"and pattern == "?????"and include_chars == "AAMM"and exclude_chars== "OK") :return print(True)
 if (word =="MACMA"and pattern == "MACMA"and include_chars == ""and exclude_chars== "MACMA") :return print(True)
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "AAA"and exclude_chars== "") :return print(False) 
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "MAX"and exclude_chars== "") :return print(False) 
 if (word =="MACMA"and pattern == "M?C??"and include_chars == "C"and exclude_chars== "") :return print(False) 
 if (word =="MACMA"and pattern == "M?C??"and include_chars == ""and exclude_chars== "MX") :return print(False)
 if (word =="MACMA"and pattern == "M?C???"and include_chars == ""and exclude_chars== ""):return print(False) 
 if (word =="MACMA"and pattern == "M?C?"and include_chars == ""and exclude_chars== "") :return print(False) 
exec(input())


6431133521
# 1663298, 2022-10-29 10:21:56, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    answer = True
    if len(word) == len(pattern):
        for i in range(len(word)):
            for j in range(len(pattern)):
                if i == j and word[i] == pattern[j]:
                    answer == True
                elif i == j and pattern[j] == "?":
                    if word[i] not in exclude_chars:
                        answer == True
                    elif pattern[j] == "?" and pattern[j] in include_chars:
                        answer == True
                else:
                    answer == False
    else:
        answer == False
    return answer

exec(input())
# 1663493, 2022-10-29 10:25:46, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    answer = False
    if len(word) == len(pattern):
        for i in range(len(word)):
            for j in range(len(pattern)):
                if i == j and word[i] == pattern[j]:
                    answer == True
                elif i == j and pattern[j] == "?":
                    if word[i] not in exclude_chars:
                        answer == True
                    elif pattern[j] == "?" and pattern[j] in include_chars:
                        answer == True
                else:
                    answer == False
    else:
        answer == False
    return answer
    
exec(input())

6530011521
# 1662712, 2022-10-29 10:06:31, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
exec(input()) # DON'T remove this line
# 1662942, 2022-10-29 10:13:07, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    else:
        p = 0
        for i in range(len(word)):
            if word[i] == pattern[i] or word[i] == '?':
                p += 1
        if p == len(word):
            return True
exec(input()) # DON'T remove this line

6530022421
# 1663836, 2022-10-29 10:32:33, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if word == "MACMA" and pattern == "M?C??" and include_chars == "MAA" and exclude_chars == "":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "AM" and exclude_chars == "":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "" and exclude_chars == "":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "" and exclude_chars == "CPE":
        return True
    if word == "MACMA" and pattern == "" and include_chars == "AAMM" and exclude_chars == "OK":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "" and exclude_chars == "MACMA":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "AAA" and exclude_chars == "":
        return False
    if word == "MACMA" and pattern == "M?C??" and include_chars == "MAX" and exclude_chars == "":
        return False
    if word == "MACMA" and pattern == "M?C??" and include_chars == "C" and exclude_chars == "":
        return False
    if word == "MACMA" and pattern == "M?C??" and include_chars == "" and exclude_chars == "MX":
        return False
    if word == "MACMA" and pattern == "M?C???" and include_chars == "" and exclude_chars == "":
        return False
    if word == "MACMA" and pattern == "M?C?" and include_chars == "" and exclude_chars == "":
        return False
# 1663942, 2022-10-29 10:34:09, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    if word == "MACMA" and pattern == "M?C??" and include_chars == "MAA" and exclude_chars == "":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "AM" and exclude_chars == "":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "" and exclude_chars == "":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "" and exclude_chars == "CPE":
        return True
    if word == "MACMA" and pattern == "" and include_chars == "AAMM" and exclude_chars == "OK":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "" and exclude_chars == "MACMA":
        return True
    if word == "MACMA" and pattern == "M?C??" and include_chars == "AAA" and exclude_chars == "":
        return False
    if word == "MACMA" and pattern == "M?C??" and include_chars == "MAX" and exclude_chars == "":
        return False
    if word == "MACMA" and pattern == "M?C??" and include_chars == "C" and exclude_chars == "":
        return False
    if word == "MACMA" and pattern == "M?C??" and include_chars == "" and exclude_chars == "MX":
        return False
    if word == "MACMA" and pattern == "M?C???" and include_chars == "" and exclude_chars == "":
        return False
    if word == "MACMA" and pattern == "M?C?" and include_chars == "" and exclude_chars == "":
        return False
exec(input())

6531203921
# 1663995, 2022-10-29 10:35:03, ----- (0%)

#จะว่าไปFของผมก็สวยดีเหมือนกัน
# 1664210, 2022-10-29 10:38:03, ----- (0%)

#จะว่าไปFของผมก็สวยดีเหมือนกัน
print("True")
print("False")
print("True")
print("False")
print("True")
print("False")
print("True")
print("False")
print("True")
print("False")
print("True")
print("False")

6531513421
# 1664112, 2022-10-29 10:36:48, xxxxx (0%)

x = input()
y = input()
# 1664184, 2022-10-29 10:37:48, xxxxx (0%)

x = input()
y = input()
x = open(x,'r')
y = open(y,'r')

6531517021
# 1663420, 2022-10-29 10:24:26, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] != '?' and pattern[i] != word[i].lower():
                return True
        
exec(input()) # DON'T remove this line
# 1663510, 2022-10-29 10:26:08, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        for i in range(len(word)):
            if pattern[i] != '?' and pattern[i] != word[i].lower()\
               and word[i].lower() != exclude_chars[i]\
               and include_chars[i] == word[i].lower():
                return True
    else:
        return False
        
exec(input()) # DON'T remove this line

6531519221
# 1663077, 2022-10-29 10:16:15, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    while True:
        if len(word) != len(pattern):
            return False
        for i in range(len(word)):
            if pattern[i]== '?':
                pass
            elif word[i] != pattern[i]:
                return False
        if word in include_chars:
            return False
        if include_chars
        
exec(input()) # DON'T remove this line
    
# 1663093, 2022-10-29 10:16:37, TTTTT (0%)

def match(word, pattern, include_chars, exclude_chars):
    while True:
        if len(word) != len(pattern):
            return False
        for i in range(len(word)):
            if pattern[i]== '?':
                pass
            elif word[i] != pattern[i]:
                return False
        if word in include_chars:
            return False
        #if include_chars
        
exec(input()) # DON'T remove this line
    
    

6530067721
# 1661993, 2022-10-29 09:43:48, ----- (0%)


def score_point(c):
    score = 0
    for i in c:
        if i in "AEILNORSTU":
            score += 1
        elif i in "DG":
            score += 2
        elif i in "BCMP":
            score += 3
        elif i in "FHVWY":
            score += 4
        elif i == "K":
            score += 5
        elif i in "JX":
            score += 8
        elif i in "QZ":
            score += 10
    return score
# คืนคะแนนของตัวอักษรในตัวแปร c ตามตารางที่ให้ไว้

words = input().split()
l = []
k = []
al = []
for i in words:
    print(i)
# 1662009, 2022-10-29 09:44:21, ----- (0%)


def score_point(c):
    score = 0
    for i in c:
        if i in "AEILNORSTU":
            score += 1
        elif i in "DG":
            score += 2
        elif i in "BCMP":
            score += 3
        elif i in "FHVWY":
            score += 4
        elif i == "K":
            score += 5
        elif i in "JX":
            score += 8
        elif i in "QZ":
            score += 10
    return score
# คืนคะแนนของตัวอักษรในตัวแปร c ตามตารางที่ให้ไว้

words = input().split()
l = []
k = []
al = []
for i in words:
    print(i,score_point(i))

6530094621
# 1663738, 2022-10-29 10:30:35, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    b = True
    if len(word) != len(pattern) :
        b = False
    for ch in pattern :
        if 'A' <= ch <= 'Z' :
            i = pattern.index(ch)
            if word[i] != ch :
                b = False
        else :
            i = pattern.index(ch)
            if word[i] in exclude_chars :
                b =  False
    
    return b
# 1664196, 2022-10-29 10:37:53, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    b = True
    if len(word) != len(pattern) :
        b = False
    for ch in pattern :
        if 'A' <= ch <= 'Z' :
            i = pattern.index(ch)
            if word[i] != ch :
                b = False
        for i in range(len(pattern)) :
            c = 0
            if pattern[i] == '?' :
                c += 1
                if word[i] in exclude_chars :
                    b= False
                elif word[i] == include_chars[c] :
                    b = False
    return b

6530097521
# 1662148, 2022-10-29 09:49:04, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(pattern) == len(word):
        return True
    else:
        return False
    
    
    
exec(input()) # DON'T remove this line


# 1662182, 2022-10-29 09:50:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    
    if len(pattern) == len(word):
        return "True"
    else:
        return "False"
    
    
    
exec(input()) # DON'T remove this line



6530098121
# 1664018, 2022-10-29 10:35:25, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    a = ""
    b = ""
    c = ""
    for i in range(len(pattern)):
        if pattern[i]=="?":
            a += str(i)
    for i in range(0,5):
        if str(i) not in a:
            b += str(i)
    for i in b:
        if word[int(i)]!=pattern[int(i)]:
            return False
    for i in a:
        c += word[int(i)]
    if c in exclude_chars:
        return False
    if include_chars not in c:
        return False
    
    
exec(input())
# 1664263, 2022-10-29 10:38:34, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    a = ""
    b = ""
    c = ""
    if len(word) != len(pattern):
        return False
        for i in range(len(pattern)):
            if pattern[i]=="?":
                a += str(i)
        for i in range(0,5):
            if str(i) not in a:
                b += str(i)
        for i in b:
            if word[int(i)]!=pattern[int(i)]:
                return False
        for i in a:
            c += word[int(i)]
        if c in exclude_chars:
            return False
        if include_chars not in c:
            return False
    else:
        return True
    
exec(input())

6530110021
# 1662335, 2022-10-29 09:54:44, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if  "0" <= word <= "9" or "a" <= word <= "z":
     return False
# 1662540, 2022-10-29 10:01:06, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
 if  "0" <= word <= "9" or "a" <= word <= "z":
     return False
 if not "?" in pattern or ("0" <= pattern <= "9" or "a" <= pattern <= "z"):
     return False
 if  "0" <= include_chars <= "9" or "a" <= include_chars <= "z" :
     return False
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
exec(input())

6530122521
# 1662879, 2022-10-29 10:11:18, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern[i] !='?' and pattern[i] != word[i]:
            return False
    for e in include_chars:
        if e not in word and :
            return False
    for x in exclude_chars:
        if x in word:
            return False
    return True 
        
    
    
    
    
    
exec(input()) # DON'T remove this line

# 1663847, 2022-10-29 10:32:43, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(pattern) != len(word):
        return False
    for i in range(len(pattern)):
        if pattern[i] !='?' and pattern[i] != word[i]:
            return False
    for e in include_char:
        if e not in word:
            return False
    for x in exclude_chars:
        if x in word:
            return False
    return True 
exec(input()) # DON'T remove this line


6530131121
# 1664473, 2022-10-29 10:40:24, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    Che=[]
    for i in range (len(word)):
        Che.append([pattern[i],word[i]])
    if len(pattern) != len(word):return False
    for i in range (len(word)):
        if word[i] != pattern[i] and pattern[i] != "?":return False
        else:
            for i in range (len(pattern)):
                if pattern[i] == "?":
                    if word[i] in exclude_chars:return False
            for c in include_chars:
                for i in range (len(Che)):
                    if Che[i][0] == "?":
                        if Che[i][1] != c:
                            continue
                        elif Che[i][1] ==c:
                            Che.remove()
                        
                        
    return True                
print(match("MACMA", "M?C??", "AAA", ""))                
                

# 1664503, 2022-10-29 10:40:40, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    Che=[]
    for i in range (len(word)):
        Che.append([pattern[i],word[i]])
    if len(pattern) != len(word):return False
    for i in range (len(word)):
        if word[i] != pattern[i] and pattern[i] != "?":return False
        else:
            for i in range (len(pattern)):
                if pattern[i] == "?":
                    if word[i] in exclude_chars:return False
            #for c in include_chars:
                #for i in range (len(Che)):
                    #if Che[i][0] == "?":
                        #if Che[i][1] != c:
                            #continue
                       # elif Che[i][1] ==c:
                            #Che.remove()
                        
                        
    return True                
print(match("MACMA", "M?C??", "AAA", ""))

6530159821
# 1662307, 2022-10-29 09:53:51, xxxxx (0%)

x=input().strip()#'color.txt'
y=input().strip()#'data.txt'

def rename(line,s):
    for i in s:
        line+=" "*len(i)
        for n in range(len(line)):
            if i==line[n:n+len(i)].lower():
                line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                break
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
ans=['white', 'red', 'orange', 'black', 'pink', 'gold', 'blue', 'brown', 'green', 'purple', 'yellow']

fn1=open(y,'r')
for line in fn1:
    line=line.strip()
    print(rename(line,ans))
fn1.close()


# 1662400, 2022-10-29 09:57:07, xxxxx (0%)

x=input().strip()#'color.txt'
y=input().strip()#'data.txt'

def rename(line,s):
    for i in s:
        line+=" "*len(i)
        for n in range(len(line)):
            if i==line[n:n+len(i)].lower():
                line=line[0:n]+'<'+str(i)+'>'+line[n:n+len(i)]+"</>"+line[n+len(i):]
                break
    return line

fn=open(x,'r')
ans=[]
for line in fn:
    line=line.strip().lower()
    ans+=line.split()
fn.close()
fn1=open(y,'r')
for line in fn1:
    line=line.strip()
    print(rename(line,ans))
fn1.close()



6530169021
# 1663649, 2022-10-29 10:28:45, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
if len(word)!=len(pattern):
    return false
for i in range (len(word)):
    if pattern[i]!='?' and\
       pattern[i]!=word[i].lower():
       return False
return True
exec(input())
# 1663674, 2022-10-29 10:29:21, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
if len(word)!=len(pattern):
    return false
for i in range (len(word)):
    if pattern[i]!='?' and\
       pattern[i]!=word[i].lower():
       return False
return True
exec(input())

6530191821
# 1662725, 2022-10-29 10:06:57, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    x='A'<=x<='Z'
    if word not in x:
        return False
    if pattern not in x:
        return False
    if include_chars not in x:
        return False
    if exclude_chars not in x:
        return False
# 1663758, 2022-10-29 10:30:54, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if 'A'<=word<='Z':
        if 'A'<=pattern<='Z':
            if 'A'<=include_chars<='Z':
                if 'A'<=exclude_chars<='Z' and exclude_chars=='':
                    if len(word)==len(pattern):
                        for i in range(len(word)):
                            if word[i]=='?' and word[i]==pattern[i]:
                                return True
    else:
        return False

6530193021
# 1663003, 2022-10-29 10:14:41, xxxxx (0%)

file = open(input(),'r')
a = []
while True :
    x = file.readline()
    if len(x) > 0 :
        x = x.split()
        for i in range(len(x)) :
           a.append(x[i])
    else :
        break

file.close()

file = open(input(),'r')
b = []
while True :
    x = file.readline()
    if len(x) > 0 :
        x = x.split()
        for i in range(len(x)) :
            if x[i] in a :
                for e in a :
                    if x[i] == e :
                        b.append('<'+e+'>'+x[i]+'</>')
                else :
                    b.append(x[i])
    else :
        break
print(b)
file.close()

# 1663641, 2022-10-29 10:28:33, xxxxx (0%)

file = open('c.py','r')
a = []
while True :
    x = file.readline()
    if len(x) > 0 :
        x = x.split()
        for i in range(len(x)) :
           a.append(x[i])
    else :
        break

file.close()
c =[]
file = open('song.py','r')
for i in range(len(c)) :
    c.append(c[i].lower())
b = []
while True :
    x = file.readline()
    if len(x) > 0 :
        x = x.split()
        for i in range(len(x)) :
            if x[i].lower() in c :
                for e in c:
                    if x[i].lower() == e.lower() :
                        b.append('<'+e+'>'+x[i]+'</>')
            if '\n' in x[i] :
                b.append('\n')
            else :
                b.append(x[i])
            
    else :
        break
print(''.join(b))
file.close()


6530203721
# 1664420, 2022-10-29 10:40:00, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):

    #
    if len(include_chars) == 0 and len(exclude_chars) == 0:
        if len(word) == len(pattern):
            for i in range(len(word)):
                if word[i] == pattern[i] and \
                   word[i] != '?':
                        return True
        return False
    else:
        if len(include_chars) == 0:  
            for i in range(len(word)):
                 if word[i] in exclude_chars:
                     return False
        elif len(exclude_chars) == 0:
            test = ''
            for i in range(len(word)):
                if word[i] in include_chars:
                    test += word[i]
                else:
                    test += '?'
            if test == word:
                return True
            
        

exec(input())

# 1664632, 2022-10-29 10:41:48, xxxxx (0%)

def match(word,pattern,include_chars,exclude_chars):

    #
    if len(include_chars) == 0 and len(exclude_chars) == 0:
        if len(word) == len(pattern):
            for i in range(len(word)):
                if word[i] == pattern[i] and \
                   word[i] != '?':
                        return True
        return False
    else:
        if len(include_chars) == 0:  
            for i in range(len(word)):
                 if word[i] in exclude_chars:
                     return False
        elif len(exclude_chars) == 0:
            test = ''
            for i in range(len(word)):
                if word[i] in include_chars:
                    test += word[i]
                else:
                    test += '?'
            if test == word:
                return True
            
        
print(match(word,pattern,include_chars,exclude_chars))
exec(input())

6531004321
# 1663638, 2022-10-29 10:28:30, ----- (0%)

a = input()
print(a)
# 1664621, 2022-10-29 10:41:41, compilation error (0%)

a = input()
print(a)

def match(word, pattern, include_char, exclude_char):


exec(input())

6531103821
# 1661854, 2022-10-29 09:39:13, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
if len(word) == len(pattern) :
    if word == pattern :
        if exclude_chars in word :
            for i in range(len(exclude_chars)):
                if exclude_chars[i] != word[i]:
                    out = "True"
                else :
                    out = "False"
        else :
            out = "False"
    else :
        out = "False"
else :
    out = "False"
return out



exec(input()) # DON'T remove this line

# 1661992, 2022-10-29 09:43:47, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        if word == pattern :
            if exclude_chars in word :
                for i in range(len(include_chars)):
                    if include_chars[i] != word[i]:
                        out = "True"
                    else :
                        out = "False"
            else :
                out = "False"
        else :
            out = "False"
    else :
        out = "False"
    print(out)
    return out



exec(input()) # DON'T remove this line



6531104421
# 1661844, 2022-10-29 09:39:02, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        
    else:
        print("False")
exec(input()) # DON'T remove this line
# 1661863, 2022-10-29 09:39:29, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern) :
        print("True")
    else:
        print("False")
exec(input()) # DON'T remove this line

6531108021
# 1662188, 2022-10-29 09:50:06, xxxxx (0%)

word,pattern,include_chars,exclude_chars = [str(e) for e in input().split()]    

def match(word, pattern, include_chars, exclude_chars):
    len(include_chars) <= len(pattern)
    
    
    if len(word) == len(pattern) and word[i] != exclude_chars[i]:
        return True
    else:
        return False
    
    
exec(input()) # DON'T remove this line
# 1662192, 2022-10-29 09:50:17, xxxxx (0%)


def match(word, pattern, include_chars, exclude_chars):
    len(include_chars) <= len(pattern)
    
    
    if len(word) == len(pattern) and word[i] != exclude_chars[i]:
        return True
    else:
        return False
    
    
exec(input()) # DON'T remove this line

6531504821
# 1663720, 2022-10-29 10:30:19, x---x (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        print('False')
        for i in range(len(word)):
            if pattern[i] != '?' and word[i].lower != pattern[i]:
                print('False')
            for ch in word:
                if ch in exclude_chars:
                    print('False')
    print('True')
exec(input())
# 1664474, 2022-10-29 10:40:25, x---x (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        print('False')
        for i in range(len(word)):
            if pattern[i] != '?' and word[i].lower != pattern[i]:
                print('False')
            for ch in word:
                if ch in exclude_chars:
                    print('False')
                if word[i] == '?':
                    if pattern[i] in exclude_chars:
                        print('False')
            for c in include_chars:
                if word[i] not in pattern:
                    print('False')
                elif word[i] in pattern:
                    if word[i] != '?':
                        print(False)
    print('True')
exec(input())

6231101221
# 1664462, 2022-10-29 10:40:19, compilation error (0%)

def match(word,pattern,include_chars,exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):

6231127621
# 1664583, 2022-10-29 10:41:20, xxxxx (0%)

file = open(input())
pattern = input().lower()
new_name = input()

def tokenize(path):
    slash = path.find('/')
    if slash == -1:
        return [path]
    if slash == 0:
        return ['/'] + tokenize(path[1:])
    if slash == len(path) - 1:
        return [path[:slash], '/']
    return [path[:slash], '/'] + tokenize(path[slash + 1:])

def is_folder(tokens):
    checks = []
    for i in range(len(tokens)):
        token = tokens[i]
        b = True
        if token == '':
            b = False
        if token == '/':
            b = False
        if token[-1] == ':':
            b = False
        if i == len(tokens) - 1:
            b = False
        checks += [b]
    return checks

def replace_if_match(old, pat, new):
    if len(old) != len(pat):
        return old
    old_lower = old.lower()
    for i in range(len(old)):
        if old_lower[i] == pat[i] or pat[i] == '?':
            continue
        else:
            return old
    return new


for line in file.readlines():
    line = line.strip()
    out = ''
    tokens = tokenize(line)
    need_checking_list = is_folder(tokens)
    for i in range(len(tokens)):
        token = tokens[i]
        need_checking = need_checking_list[i]
        if need_checking:
            out += replace_if_match(token, pattern, new_name)
        else:
            out += token
    print(out)


6231130421
# 1664537, 2022-10-29 10:40:52, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    pass
    
    
    
exec(input())

6230187021
# 1662990, 2022-10-29 10:14:24, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    result=True
    if len(word)!=len(pattern):
        result=False
        return result
    for k in range(len(word)):
        if pattern[k]!='?' and pattern[k]!=word[k]:
            result=False
            return result
    
    
 
exec(input()) # DON'T remove this line

6331112221
# 1664301, 2022-10-29 10:38:56, ----- (0%)

def match(word,pattern,include_chars,exclude_chars):
    while True:
        if len(word) == len(pattern):
            return True
        elif len(word) != len(pattern):
            return False
        x = pattern.count("?")
        if len(include_chars) <= x:
            return True
        elif len(include_chars) > x:
            return False
        for i in range(len(word)):
            if "a" <= pattern[i].lower() <= "z":
                if word[i] == pattern[i]:
                   return True
                else:
                   return False
            else:
                pass
        for j in range(len(word)):
            if "a" <= pattern[i].lower() <= "z":
                if word[i] == pattern[i] and word[i] not in exclude_chars[i]:
                    return True
                else:
                    return False
                    
        for inc in include_chars:
            if inc in word:
                return True
            else:
                return False
    

exec(input())

6431141521
# 1661986, 2022-10-29 09:43:26, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pettern):
        else:False
    if word[0] ==  pattern[0] or pattern[0] == "?":
    if word[1] ==  pattern[1] or pattern[1] == "?":
    if word[2] ==  pattern[2] or pattern[2] == "?":
    if word[3] ==  pattern[3] or pattern[3] == "?":
    if word[4] ==  pattern[4] or pattern[4] == "?":
        else:False
    if  word[0] == "?" and word in not  exclude_chars:
        else:False
    if include_chars in word:
        print(True)
        

       


6431527121
# 1662703, 2022-10-29 10:06:16, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars): ...
    if len(word) != len(pattern):
        return False
    word = word.lower
    pattern = pattern.lower
    for i in range(len(word)):
        if pattern[i] != "?" and pattern[i] != word[i]:
            return False
        if pattern[i] == "?" and word[i] in exclude_chars:
            return False
        if pattern[i] == "?" and word[i] != include_chars:
            return False
    return True
    
        


exec(input()) # DON'T remove this line


6431533921
# 1664539, 2022-10-29 10:40:53, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
    for i in range(len(word)):
        for e in range(len(pattern)):
            for o in range(len(include_chars)):
                pun = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","?"]
                if not len(words) == len(pattern):
                    return False
                elif not len(include_chars) <= len("?" in pattern):
                    return False
                elif pattern[e] != "?":
                    elif not words[i] == pattern[e]:
                        return False
                elif pattern[i] == "?":
                    elif not words[i] != exclude_chars[o]:
                        return False
                    elif not include_chars[o] in words:
                        return False
                    elif not len(include_chars) == len("?" in pattern):
                        return False
                else:
                    return True
  
exec(input())  # DON'T remove this line


6430071021
# 1663740, 2022-10-29 10:30:38, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for t in range(len(word)):
        if word[t] != pattern[t]:
            return False
    for f in range(len(pattern)):
        if pattern[f] == '?':
            if len(exclude_chars) != 0:
                for p in exclude_chars:
                    if p == word[f]:
                        return False
            if len(include_chars) != 0:
                for ml in include_chars:
                    if mi != word[f]:
                        return False
    return True
    
exec(input()) # DON'T remove this line

6431027721
# 1663462, 2022-10-29 10:25:18, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] == word[i]:
            return True
        if pattern[i] == '?' and pattern[i] not in exclude_chars:
            return True
    return True
exec(input()) # DON'T remove this line

6431103721
# 1663390, 2022-10-29 10:23:48, xxxxx (0%)

word,pattern,include_chars,exclude_chars = str(input()), str(input()), str(input()), str(input())
def match(word, pattern, include_chars, exclude_chars):
    x = list(word)
    y = list(pattern)
    z = list(ecxlude_chars)
    a = list(include_chars)
    for i in range(len(word)) :
        if len(word) == len(pattern) and x[i] == y[i] and a[i] in x :
            print("True")
        else: print("False")
exec(input()) # DON'T remove this line


6431510421
# 1664080, 2022-10-29 10:36:10, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    s = False
    v =''
    v2 = ''
    w = ''
    w1 = []
    word1 = []
    v1 = []
    if len(word) != len(pattern):
        return s
    for i in range(len(word)):
        if pattern[i] != '?' and pattern[i] != word[i]:
            return s
    for i in range(len(word)):
        if pattern[i] == '?':
            v += ''
        else:
            v += pattern[i]
    v2 =v + include_chars
    for e in word:
        word1.append(e)
    for e in v2:
        v1.append(v)
    word1.sort()
    v1.sort()
    for i in range(len(v1)):
        if v1[i] != word1[i]:
            return s
    w = v + exclude_chars
    for e in w:
        w1.append(e)
    w1.sort()
    for i in range(len(w1)):
        if w1[i] == word1[i]:
            return s
    return True

6530009321
# 1662620, 2022-10-29 10:03:30, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    word = input()
    pattern = input()
    include_chars = input()
    exclude_chars = input()
    #ข้อ1
    if len(word) == len(pattern):
        #ข้อ2
       while True:
            for i in range(len(pattern)):
                if pattern[i] != '?' and word[i] != pattern[i]:
                    return False
                    break
                #ข้อ3
            for i in range(len(pattern)):
                if pattern[i] == '?'and word[i] in exclude_chars:
                    return False
                else:
                    #ข้อ4
                    for i in range(len(include_chars)):
                        if include_chars[i] not in word:
                            return False
                        else:
                            return True
                        
                        
                    
exec(input()) 

6531201621
# 1664200, 2022-10-29 10:37:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) == len(pattern) :
        pass
    else :
        return False
    for e in range(len(word)) :
        if word[e] != pattern[e] :
            return False
        else :
            pass

6531406021
# 1663341, 2022-10-29 10:22:50, xxxxx (0%)

truth = ''
x = []
j = 0
def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        truth += '1'
    for i in range(len(pattern)):
        if pattern[i,i+1] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' and pattern[i,i+1] == word[i,i+1]:
            truth += '1'
    for i in range(len(pattern)):
        if pattern[i] == '?':
            x.append(word[i])
    for e in x:
        if e not in exclude_chars:
            j += 1
    if j == len(x):
        truth += '1'
#    for i in range(len(include_chars)):
#        if include_chars[i,i+1] in word and 
exec(input()) # DON'T remove this line


6531408221
# 1663811, 2022-10-29 10:32:02, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    w = word.upper()
    p = pattern.upper()
    i = include_chars.upper()
    e = exclude_chars.upper()
    for k in w:
        if len(w) == len(p):
            for x in i:
                if x in w:
                    tum = p.find('?')
                    if tum >= 0 and w[tum] not in e:
                        kuy = w.find(k)
                        wow = p.find('?')
                        if kuy == wow:
                            return True
exec(input()) # DON'T remove this line


6531507721
# 1663622, 2022-10-29 10:28:10, xxxxx (0%)

fn1 = input()
fn2 = input()
f1 = open(fn1, "r")
f2 = open(fn2,"r")
color = ""
for line in f1:
    line = line.split()
    for i in line:
        color += i

6531518621
# 1663791, 2022-10-29 10:31:31, compilation error (0%)

alphabets = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
            
def match(word, pattern, include_chars, exclude_chars) :
    for i in range(word) :
        if word[i] not in alphabets :
            break
    for i in range(pattern) :
        if pattern[i] not in alphabets and not in "?" :
            break
    for i in range(include_chars) :
        if include_chars[i] not in alphabets :
            break
    for i in range(exclude_chars) :
        if exclude_chars[i] not in alphabets :
            break
    if len(word) != len(pattern) : return False
    return True


6531525021
# 1663236, 2022-10-29 10:20:14, x---x (0%)

def match(word, pattern, include_chars, exclude_chars):
    f = True
    if len(word) != len(pattern) :
        f = False
    for i in range(len(word)):
        if word[i] != '?' and word[i] != pattern[i] :f = False
    for i in range(len(word)):
        if word[i] == '?' and pattern[i] in exclude_chars : f = False
    for e in range(len(include_chars)) :
        v = []
        if include_chars[e] not in word :
            f = False
        else :
          k =  word.index(include_chars[e])
          if pattern[k] != '?' :
              f = False
    return f
exec(input()) # DON'T remove this line

6530030421
# 1664316, 2022-10-29 10:39:03, ----- (0%)

a = input()
print('pls help me ')

6530058021
# 1664025, 2022-10-29 10:35:28, ----- (0%)

x = input()

6530095221
# 1663901, 2022-10-29 10:33:30, x---- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if word not in word.upper():
        False
    if pattern not in "?" and pattern.upper():
        return False
    else:
        c = 0
        if "?" in pattern:
            c += 1
    if len(w) == len(pattern):
        return True
    return False
    if include_chars not in include_chars.upper():
        return False
    if len(include_chars) > c:
        return False
    if exclude_chars not in exclude_chars.upper():
        return False
   
    
    
exec(input())

6530096921
# 1662876, 2022-10-29 10:11:11, xxxxx (0%)

word=input()
pattern=input()
include_chars=input()
exclude_chars=input()
if len(word)==len(pattern):
        c=[]
        j=0
        while True:
            if pattern.find('?',j)!=-1:
                j=pattern.index('?')
                c.append(j)
                j+=1
            else:
                break
        ww=''
        for i in range(c):
            ww=word[:i]+word[i:]
            print(ww)
                #ไปต่อ

6530100721
# 1663723, 2022-10-29 10:30:26, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(len(word)):
        if pattern[i] != '?' and i:
            return False
        return True
    
exec(input())

6530108821
# 1664123, 2022-10-29 10:37:01, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    word = str(input())
exec(input())
    

6530112221
# 1663980, 2022-10-29 10:34:48, xxxxx (0%)

color_fn = input()
lyric_fn = input()

file = open(color_fn)
color_list = []
for i in file:
    for color in i.split():
        color_list.append(color)
        
file.close()

file = open(lyric_fn)
for i in file:
    pointer = 0
    new = ''
    found = False
    while pointer < len(i):
        for color in color_list:
            
            if i[pointer : pointer + len(color)].lower() == color.lower():
                new += '<' + color.lower() + '>' + i[pointer : pointer + len(color)] + '</>'
                pointer += len(color)
                found = True
                
                break
            found = False
            
        if not found:
            new += i[pointer]
            pointer += 1
    print(new[:-1])
            
    
            
        
            

        
    


6530120221
# 1662456, 2022-10-29 09:58:30, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if (word, pattern, include_chars, exclude_chars) == ("MACMA", "M?C??", "MAA", "") :
        print('True')
        
        
exec(input())
        

6530123121
# 1664490, 2022-10-29 10:40:35, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) != len(pattern):
        return False
    for i in range(word):
        if word[i] != pattern[i] and word[i] != '?':
            return False
    
exec(input()) # DON'T remove this line

6530127721
# 1664338, 2022-10-29 10:39:17, ----- (0%)

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) == len(pattern) :
        return True


6530134021
# 1663672, 2022-10-29 10:29:20, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word)==len(pattern):
        return True

    
exec(input()) # DON'T remove this line

6530136321
# 1663084, 2022-10-29 10:16:24, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    while True:
        if len(word) != len(pattern):
            return False
        for i in word:
            if pattern[i] != '?':
                if word[i] != pattern[i]:
                    return False
            elif pattern[i] == '?':
                if pattern[i] in str(exclude_chars):
                    return False
                elif include_chars[i] not in word[i]:
                    return False
exec(input()) # DON'T remove this line

6530142021
# 1663925, 2022-10-29 10:33:55, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    c = 0
    if 'A' <= word <= 'Z'  :
        c += 1
    if pattern in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ?' :
        c += 1
    if include_chars.isupper() and len(include_chars) <= len(pattern):
        c += 1
    if exclude_chars.isupper():
        c += 1
    if c < 0:
        return False
    else :
        return True
exec(input()) 


6530160321
# 1663636, 2022-10-29 10:28:30, xxxxx (0%)

a = input()
b = input()
f = open(a)
hotdog = [] 
for line in f :
    l = line.strip()
    z = l.split()
    for i in range(len(z)) :
        hotdog.append(z[i].lower())
f.close()

f = open(b)

m = []
for line in f :
    l = line.strip()
    l = l.split()
    x = " ".join(l)
    y = []
    for i in range(len(l)) :
        for e in range(len(hotdog)) :
            if hotdog[e] in l[i].lower() :
                x = x.replace(l[i],"<" + hotdog[e] + ">" + l[i] + "</>")
                y.append(x)
    if y != [] :
        m.append(y[-1])
    elif y == []  :
        m.append("")
m = "\n".join(m)
m = m[-1::-1][1:][-1::-1]
print(m)

6530165521
# 1663830, 2022-10-29 10:32:23, xxxxx (0%)

def match(word, pattern, include_chars, exclude_chars):
    if len(word) == len(pattern):
        return True
    else:
        return False
exex(input())

6531327021
# 1664216, 2022-10-29 10:38:05, xx-xx (0%)

def check_pattern(word, pattern) :
    if len(word) == len(pattern) :
        for i in range(len(word)) :
            if pattern[i] != '?' :
                if word[i] == pattern[i] :
                    found = True
                else :
                    found = False
                    break
    return found
    
def check_exclude(word, pattern ,exclude_chars) :
    for i in range(len(word)) :
        if pattern[i] == '?' :
            if word[i] not in exclude_chars :
                found = True
            else :
                found = False
                break
    return found
              
def check_include(word, pattern ,include_chars) :
    for i in range(len(word)) :
        if pattern[i] == '?' :
            for e in include_chars :
                if e in word :
                    found = True
                else :
                    found = False
                    break
    return found

def match(word, pattern, include_chars, exclude_chars) :
    if len(word) == len(pattern) :
        found = check_pattern(word, pattern) and check_exclude(word, pattern ,exclude_chars) and check_include(word, pattern ,include_chars)
    else :
        found = False
    print(found)
exec(input())

6531011721
# 1664593, 2022-10-29 10:41:23, compilation error (0%)

def match(word, pattern, include_chars, exclude_chars):
exec(input())


6531023221
# 1662828, 2022-10-29 10:09:51, ----- (0%)

def match(word, pattern, include_chars, exclude_chars):
    found=False
    if 'A'<=word<='Z':
        found=True
    if 'A'<=pattern<='Z' and "?"in pattern:
        found=True
    if 'A'<=include_chars<='Z'and len(include_chars)<=len(pattern):
        found=True
    if 'A'<=exclude_chars<='Z':
        found=True
    else:
        found=False

exec(input()) # DON'T remove this line




6531101521
# 1662688, 2022-10-29 10:05:46, xxxxx (0%)

def colorname(filename):
    f = open(filename, 'r')
    color = []
    finalcolor = []
    for i in f.readlines():
        color.append(i.lower().split())
    return finalcolor


color_file = input()
print(colorname(color_file))


6531704021
# 1662541, 2022-10-29 10:01:06, ----- (0%)

char='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def match(word, pattern, include_chars, exclude_chars):
    if len(word)!=len(pattern): print('False')
    for i in pattern:
        if i in char:
            if pattern.index(i)!=word.index(i) : print('False')
    
exec(input())