#include <iostream>
#include <regex>
#include <string>
 
int main()
{
    std::vector<std::string> str;
    std::vector<std::string> list;
    
    std::string tmp;
    do
    {
        std::cin >> tmp;
        list.push_back(tmp);
    } while (tmp != "END");
    
    do
    {
        std::cin >> tmp;
        str.push_back(tmp);
    } while (tmp != "END");
        
    for(auto& it : list)
    {
        std::cout << "Regex: " << it << std::endl;
        for(int i = 0; i < str.size(); ++i)
        {
            std::regex pattern(it, std::regex_constants::basic);
            std::cout <<  std::regex_match(str[i], pattern) << std::endl;
        }  
    }
    return 0;
}