#include int main() { std::map< char, std::string > letters; std::map< std::string, int > words; for(int i=0;i<=25;i++) { char ch; std::string rep; std::cin>>ch>>rep; letters[ ch ]=rep; } int n; std::cin>>n; int sol=0; for(;n;n--) { std::string morseRep,word; morseRep=""; std::cin>>word; for(auto letter: word) morseRep+=letters[ letter ]; words[ morseRep ]++; sol = std::max(sol, words[ morseRep ]); } if(sol == 1) sol = -1; std::cout<